Esempio n. 1
0
 /**
  * Set avatar from social account
  * 
  * @param type $id 
  */
 public function avatar_action($id)
 {
     $loginza = new Db_ORM('users_loginza');
     $loginza->id = $id;
     if ($loginza->find() && ($this->user->id == $id or access('loginza delete_all'))) {
         if ($loginza->photo) {
             $user = new User_Object();
             $user->id = $this->user->id;
             $path = UPLOADS . DS . 'avatars' . DS . $this->user->id . DS . basename($loginza->photo);
             copy($loginza->photo, $path);
             $user->avatar = Url::toUri($path, UPLOADS);
             $user->save();
             Ajax::json(array('action' => 'reload'));
         }
     } else {
         Ajax::denied();
     }
 }
Esempio n. 2
0
 /**
  * Gears dispatcher
  * 
  * @param string $action
  * @param string $gear 
  */
 public function index($action = NULL, $gear = NULL)
 {
     if (!access('admin gears')) {
         Ajax::denied();
     }
     switch ($action) {
         case 'activate':
             cogear()->activate($gear);
             $tpl = new Template('Gears.item');
             $tpl->assign($this->{$gear}->info());
             Ajax::json(array('items' => array(array('id' => 'gear-' . $gear, 'action' => 'replace', 'code' => $tpl->render()))));
             break;
         case 'deactivate':
             cogear()->deactivate($gear);
             $tpl = new Template('Gears.item');
             $name = strtolower($gear);
             $tpl->assign($this->{$name}->info());
             Ajax::json(array('items' => array(array('id' => 'gear-' . $gear, 'action' => 'replace', 'code' => $tpl->render()))));
             break;
     }
 }