123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- defined('GNUSOCIAL') || die();
- class User_flag_profile extends Managed_DataObject
- {
-
-
- public $__table = 'user_flag_profile';
- public $profile_id;
- public $user_id;
- public $cleared;
- public $created;
- public $modified;
-
-
- public static function schemaDef()
- {
- return array(
- 'fields' => array(
- 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile id flagged'),
- 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id of the actor'),
- 'cleared' => array('type' => 'datetime', 'description' => 'when flag was removed'),
- 'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
- 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
- ),
- 'primary key' => array('profile_id', 'user_id'),
- 'indexes' => array(
- 'user_flag_profile_cleared_idx' => array('cleared'),
- 'user_flag_profile_created_idx' => array('created'),
- ),
- );
- }
-
- public static function exists($profile_id, $user_id)
- {
- $ufp = User_flag_profile::pkeyGet(array('profile_id' => $profile_id,
- 'user_id' => $user_id));
- return !empty($ufp);
- }
-
- public static function create($user_id, $profile_id)
- {
- $ufp = new User_flag_profile();
- $ufp->profile_id = $profile_id;
- $ufp->user_id = $user_id;
- $ufp->created = common_sql_now();
- if (!$ufp->insert()) {
-
-
- $msg = sprintf(
- _m('Could not flag profile "%d" for review.'),
- $profile_id
- );
- throw new ServerException($msg);
- }
- $ufp->free();
- return true;
- }
- }
|