public static function add($type, $reference = 0, $data = '')
 {
     $session = SessionHandler::getInstance();
     $c = new ModerationObject();
     $c->type = $type;
     $c->owner = $session->id;
     $c->time_created = sql_datetime(time());
     $c->data = $data;
     $c->reference = $reference;
     $c->id = $c->store();
     return $c->id;
 }
Beispiel #2
0
 function handleEditUsername($p)
 {
     $p['new_user'] = trim($p['new_user']);
     $error = ErrorHandler::getInstance();
     $session = SessionHandler::getInstance();
     // dont put empty names or current username on request queue
     if (!$p['new_user'] || $p['new_user'] == $session->username) {
         $error->add('Useless request');
         return false;
     }
     if (User::getByName($p['new_user'])) {
         $error->add('Username taken');
         return false;
     }
     if (ReservedWord::isReservedUsername($p['new_user'])) {
         $error->add('Username is reserved');
         return false;
     }
     // put request on queue for admins
     ModerationObject::add(MODERATE_CHANGE_USERNAME, $p['new_user']);
     echo '<div class="good">Your request for username change have been submitted and will be handled soon!</div>';
 }
Beispiel #3
0
     //,    'link', 'a/moderation/handle/', 'name');
     $dt->addColumn('owner', 'Owner', 'link', 'a/user/', 'name');
     $dt->addColumn('type', 'Type', 'array', getModerationTypes());
     $dt->addColumn('time_created', 'Created');
     $dt->addColumn('time_handled', 'Denied');
     $dt->addColumn('handled_by', 'Denied by', 'link', 'a/user/', 'name');
     $dt->addColumn('data', 'Data');
     $dt->addColumn('reference', 'Reference');
     $dt->setDataSource($list);
     echo $dt->render();
     break;
 case 'handle':
     if (!$this->child) {
         die('SADFGFG');
     }
     $o = ModerationObject::get($this->child);
     //    d($o);
     if (isset($_GET['approve']) || isset($_GET['deny'])) {
         $o->handled_by = $session->id;
         $o->time_handled = sql_datetime(time());
         $o->approved = isset($_GET['approve']) ? 1 : 0;
         $o->store();
         if (!isset($_GET['approve'])) {
             redir('a/moderation');
         }
         switch ($o->type) {
             case MODERATE_CHANGE_USERNAME:
                 if (UserFinder::byUsername($o->data)) {
                     return;
                 }
                 // perform the username switch
Beispiel #4
0
 function handleReportPhoto($p)
 {
     ModerationObject::add(MODERATE_PHOTO, $p['id'], $p['reason']);
     js_redirect('u/photo/show/' . $p['id']);
 }