예제 #1
0
 public function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     // remove all the permissions
     $perm = Pluf_Permission::getFromString('IDF.project-authorized-user');
     $cm = $this->project->getMembershipData();
     $guser = new Pluf_User();
     foreach ($cm['authorized'] as $user) {
         Pluf_RowPermission::remove($user, $this->project, $perm);
     }
     if ($this->cleaned_data['private_project']) {
         foreach (preg_split("/\r\n|\r|\n|\\,/", $this->cleaned_data['authorized_users'], -1, PREG_SPLIT_NO_EMPTY) as $login) {
             $sql = new Pluf_SQL('login=%s', array(trim($login)));
             $users = $guser->getList(array('filter' => $sql->gen()));
             if ($users->count() == 1) {
                 Pluf_RowPermission::add($users[0], $this->project, $perm);
             }
         }
         $this->project->private = 1;
     } else {
         $this->project->private = 0;
     }
     $this->project->update();
     $this->project->membershipsUpdated();
 }
예제 #2
0
 function postSave($create = false)
 {
     if ($create) {
         // Check if more than one revision for this page. We do
         // not want to insert the first revision in the timeline
         // as the page itself is inserted.  We do not insert on
         // update as update is performed to change the is_head
         // flag.
         $sql = new Pluf_SQL('wikipage=%s', array($this->wikipage));
         $rev = Pluf::factory('IDF_WikiRevision')->getList(array('filter' => $sql->gen()));
         if ($rev->count() > 1) {
             IDF_Timeline::insert($this, $this->get_wikipage()->get_project(), $this->get_submitter());
             foreach ($rev as $r) {
                 if ($r->id != $this->id and $r->is_head) {
                     $r->is_head = false;
                     $r->update();
                 }
             }
         }
         $page = $this->get_wikipage();
         $page->update();
         // Will update the modification timestamp.
         IDF_Search::index($page);
     }
 }
예제 #3
0
 /**
  * Send the reminder email.
  *
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     $account = $this->cleaned_data['account'];
     $sql = new Pluf_SQL('email=%s OR login=%s', array($account, $account));
     $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
     $return_url = '';
     foreach ($users as $user) {
         if ($user->active) {
             $return_url = Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecoveryInputCode');
             $tmpl = new Pluf_Template('idf/user/passrecovery-email.txt');
             $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
             $code = trim($cr->encrypt($user->email . ':' . $user->id . ':' . time()), '~');
             $code = substr(md5(Pluf::f('secret_key') . $code), 0, 2) . $code;
             $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecovery', array($code), array(), false);
             $urlic = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views::passwordRecoveryInputCode', array(), array(), false);
             $context = new Pluf_Template_Context(array('url' => Pluf_Template::markSafe($url), 'urlik' => Pluf_Template::markSafe($urlic), 'user' => Pluf_Template::markSafe($user), 'key' => Pluf_Template::markSafe($code)));
             $email = new Pluf_Mail(Pluf::f('from_email'), $user->email, __('Password Recovery - InDefero'));
             $email->setReturnPath(Pluf::f('bounce_email', Pluf::f('from_email')));
             $email->addTextMessage($tmpl->render($context));
             $email->sendMail();
         }
         if (!$user->active and $user->first_name == '---') {
             $return_url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
             IDF_Form_Register::sendVerificationEmail($user);
         }
     }
     return $return_url;
 }
예제 #4
0
파일: Commit.php 프로젝트: burbuja/indefero
 /**
  * Create a commit from a simple class commit info of a changelog.
  *
  * @param stdClass Commit info
  * @param IDF_Project Current project
  * @return IDF_Commit
  */
 public static function getOrAdd($change, $project)
 {
     $sql = new Pluf_SQL('project=%s AND scm_id=%s', array($project->id, $change->commit));
     $r = Pluf::factory('IDF_Commit')->getList(array('filter' => $sql->gen()));
     if ($r->count() > 0) {
         $r[0]->extra = new IDF_Gconf();
         $r[0]->extra->serialize = true;
         $r[0]->extra->setModel($r[0]);
         $r[0]->extra->initCache();
         return $r[0];
     }
     if (!isset($change->full_message)) {
         $change->full_message = '';
     }
     $scm = IDF_Scm::get($project);
     $commit = new IDF_Commit();
     $commit->project = $project;
     $commit->scm_id = $change->commit;
     $commit->summary = self::toUTF8($change->title);
     $commit->fullmessage = self::toUTF8($change->full_message);
     $commit->author = $scm->findAuthor($change->author);
     $commit->origauthor = self::toUTF8($change->author);
     $commit->creation_dtime = $change->date;
     $commit->create();
     $extra = $scm->getExtraProperties($change);
     $commit->extra = new IDF_Gconf();
     $commit->extra->serialize = true;
     // As we can store arrays
     $commit->extra->setModel($commit);
     foreach ($extra as $key => $val) {
         $commit->extra->setVal($key, $val);
     }
     $commit->notify($project->getConf());
     return $commit;
 }
예제 #5
0
파일: Group.php 프로젝트: burbuja/pluf
 /**
  * Predelete to drop the row level permissions.
  */
 function preDelete()
 {
     if (Pluf::f('pluf_use_rowpermission', false)) {
         $_rpt = Pluf::factory('Pluf_RowPermission')->getSqlTable();
         $sql = new Pluf_SQL('owner_class=%s AND owner_id=%s', array($this->_a['model'], $this->_data['id']));
         $this->_con->execute('DELETE FROM ' . $_rpt . ' WHERE ' . $sql->gen());
     }
 }
예제 #6
0
파일: Shortcuts.php 프로젝트: burbuja/pluf
/**
 * Get an object by SQL or raise a 404 error.
 *
 * Usage:
 * <pre>
 * $obj = Pluf_Shortcuts_GetOneOr404('MyApp_Model',
 *                                   'path=%s AND status=%s',
 *                                    array('welcome', 1));
 * </pre>
 *
 * @param string Model
 * @param string Base SQL request
 * @param string Parameters for the base SQL
 * @return Object The found object
 */
function Pluf_Shortcuts_GetOneOr404($object, $bsql, $psql)
{
    $sql = new Pluf_SQL($bsql, $psql);
    $item = Pluf::factory($object)->getOne(array('filter' => $sql->gen()));
    if ($item != null) {
        return $item;
    }
    throw new Pluf_HTTP_Error404();
}
예제 #7
0
파일: Permission.php 프로젝트: burbuja/pluf
 /**
  * Get the matching permission object from the permission string.
  *
  * @param string Permission string, for example 'Pluf_User.create'.
  * @return false|Pluf_Permission The matching permission or false.
  */
 public static function getFromString($perm)
 {
     list($app, $code) = explode('.', trim($perm));
     $sql = new Pluf_SQL('code_name=%s AND application=%s', array($code, $app));
     $perms = Pluf::factory('Pluf_Permission')->getList(array('filter' => $sql->gen()));
     if ($perms->count() != 1) {
         return false;
     }
     return $perms[0];
 }
예제 #8
0
 function clean_email()
 {
     $this->cleaned_data['email'] = mb_strtolower(trim($this->cleaned_data['email']));
     $guser = new Pluf_User();
     $sql = new Pluf_SQL('email=%s', $this->cleaned_data['email']);
     if ($guser->getCount(array('filter' => $sql->gen())) > 0) {
         throw new Pluf_Form_Invalid(sprintf(__('The email "%s" is already used. If you need, click on the help link to recover your password.'), $this->cleaned_data['email']));
     }
     return $this->cleaned_data['email'];
 }
예제 #9
0
 public function findAuthor($author)
 {
     // We extract the email.
     $match = array();
     if (!preg_match('/<(.*)>/', $author, $match)) {
         return null;
     }
     $sql = new Pluf_SQL('email=%s', array($match[1]));
     $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
     return $users->count() > 0 ? $users[0] : null;
 }
예제 #10
0
파일: Conf.php 프로젝트: burbuja/indefero
 function delVal($key, $initcache = true)
 {
     $gconf = new IDF_Conf();
     $sql = new Pluf_SQL('vkey=%s AND project=%s', array($key, $this->_project->id));
     foreach ($gconf->getList(array('filter' => $sql->gen())) as $c) {
         $c->delete();
     }
     if ($initcache) {
         $this->initCache();
     }
 }
예제 #11
0
파일: Git.php 프로젝트: Br3nda/indefero
 /**
  * Get for the given hashes the corresponding date, title and
  * author.
  *
  * It returns an hash indexed array with the info. If an hash is
  * not in the db, the key is not set.
  *
  * Note that the hashes must always come from internal tools.
  *
  * @param array Hashes to get info
  * @return array Blob infos
  */
 public function retrieve($hashes)
 {
     $res = array();
     $db = $this->getDbConnection();
     $hashes = array_map(array($db, 'esc'), $hashes);
     $sql = new Pluf_SQL('project=%s AND githash IN (' . implode(', ', $hashes) . ')', array($this->_project->id));
     foreach (Pluf::factory(__CLASS__)->getList(array('filter' => $sql->gen())) as $blob) {
         $tmp = explode(chr(31), $blob->content, 3);
         $res[$blob->githash] = (object) array('hash' => $blob->githash, 'date' => $tmp[0], 'title' => $tmp[2], 'author' => $tmp[1]);
     }
     return $res;
 }
예제 #12
0
 function callbackWikiPage($m)
 {
     $sql = new Pluf_SQL('project=%s AND title=%s', array($this->project->id, $m[2]));
     $pages = Pluf::factory('IDF_WikiPage')->getList(array('filter' => $sql->gen()));
     if ($pages->count() != 1 and $this->request->rights['hasWikiAccess'] and !$this->request->user->isAnonymous()) {
         return '<img style="vertical-align: text-bottom;" alt=" " src="' . Pluf::f('url_media') . '/idf/img/add.png" /><a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::create', array($this->project->shortname), array('name' => $m[2])) . '" title="' . __('Create this documentation page') . '">' . $m[1] . '</a>';
     }
     if (!$this->request->rights['hasWikiAccess'] or $pages->count() == 0) {
         return $m[1];
     }
     return '<a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', array($this->project->shortname, $pages[0]->title)) . '" title="' . Pluf_esc($pages[0]->summary) . '">' . $m[1] . '</a>';
 }
예제 #13
0
 public function clean_mtn_master_branch()
 {
     $mtn_master_branch = mb_strtolower($this->cleaned_data['mtn_master_branch']);
     if (!preg_match('/^([\\w\\d]+([-][\\w\\d]+)*)(\\.[\\w\\d]+([-][\\w\\d]+)*)*$/', $mtn_master_branch)) {
         throw new Pluf_Form_Invalid(__('The master branch is empty or contains illegal characters, ' . 'please use only letters, digits, dashs and dots as separators.'));
     }
     $sql = new Pluf_SQL('vkey=%s AND vdesc=%s AND project!=%s', array('mtn_master_branch', $mtn_master_branch, (string) $this->project->id));
     $l = Pluf::factory('IDF_Conf')->getList(array('filter' => $sql->gen()));
     if ($l->count() > 0) {
         throw new Pluf_Form_Invalid(__('This master branch is already used. Please select another one.'));
     }
     return $mtn_master_branch;
 }
예제 #14
0
 public function clean_title()
 {
     $title = $this->cleaned_data['title'];
     if (preg_match('/[^a-zA-Z0-9\\-]/', $title)) {
         throw new Pluf_Form_Invalid(__('The title contains invalid characters.'));
     }
     $sql = new Pluf_SQL('project=%s AND title=%s', array($this->project->id, $title));
     $pages = Pluf::factory('IDF_WikiPage')->getList(array('filter' => $sql->gen()));
     if ($pages->count() > 0) {
         throw new Pluf_Form_Invalid(__('A page with this title already exists.'));
     }
     return $title;
 }
예제 #15
0
 function postSave($create = false)
 {
     if ($create) {
         // Check if more than one comment for this issue. We do
         // not want to insert the first comment in the timeline as
         // the issue itself is inserted.
         $sql = new Pluf_SQL('issue=%s', array($this->issue));
         $co = Pluf::factory('IDF_IssueComment')->getList(array('filter' => $sql->gen()));
         if ($co->count() > 1) {
             IDF_Timeline::insert($this, $this->get_issue()->get_project(), $this->get_submitter());
         }
     }
     IDF_Search::index($this->get_issue());
 }
예제 #16
0
 /**
  * Validate the key.
  */
 public function clean_key()
 {
     $this->cleaned_data['key'] = trim($this->cleaned_data['key']);
     $error = __('We are sorry but this confirmation key is not valid. Maybe you should directly copy/paste it from your confirmation email.');
     if (false === ($email_id = self::checkKeyHash($this->cleaned_data['key']))) {
         throw new Pluf_Form_Invalid($error);
     }
     $guser = new Pluf_User();
     $sql = new Pluf_SQL('email=%s AND id=%s', $email_id);
     if ($guser->getCount(array('filter' => $sql->gen())) != 1) {
         throw new Pluf_Form_Invalid($error);
     }
     return $this->cleaned_data['key'];
 }
예제 #17
0
 /**
  * Validate the key.
  */
 public function clean_key()
 {
     $this->cleaned_data['key'] = trim($this->cleaned_data['key']);
     $error = __('We are sorry but this validation key is not valid. Maybe you should directly copy/paste it from your validation email.');
     if (false === ($cres = IDF_Form_PasswordInputKey::checkKeyHash($this->cleaned_data['key']))) {
         throw new Pluf_Form_Invalid($error);
     }
     $guser = new Pluf_User();
     $sql = new Pluf_SQL('email=%s AND id=%s', array($cres[0], $cres[1]));
     if ($guser->getCount(array('filter' => $sql->gen())) != 1) {
         throw new Pluf_Form_Invalid($error);
     }
     if (time() - $cres[2] > 86400) {
         throw new Pluf_Form_Invalid(__('Sorry, but this verification key has expired, please restart the password recovery sequence. For security reasons, the verification key is only valid 24h.'));
     }
     return $this->cleaned_data['key'];
 }
예제 #18
0
 public static function remove($owner, $object, $perm)
 {
     if (!is_object($perm)) {
         $found = Pluf_Permission::getFromString($perm);
         if (false === $found) {
             throw new Exception(sprintf('The permission %s does not exist.', $perm));
         }
         $perm = $found;
     }
     $growp = new Pluf_RowPermission();
     $sql = new Pluf_SQL('owner_id=%s AND owner_class=%s AND model_id=%s AND model_class=%s AND permission=%s', array($owner->id, $owner->_a['model'], $object->id, $object->_a['model'], $perm->id));
     $perms = $growp->getList(array('filter' => $sql->gen()));
     foreach ($perms as $p) {
         $p->delete();
     }
     return true;
 }
예제 #19
0
 public function testChainSQLAndOr()
 {
     $sql1 = new Pluf_SQL('title=%s', 'my title');
     $sql2 = Pluf::factory('Pluf_SQL');
     $sql1->Q('description=%s', '%par example')->Q('keywords=%s', "tag'gi`ng");
     $sql3 = Pluf::factory('Pluf_SQL');
     $sql3->Q('status=%s', '1');
     $sql1->SOr($sql3);
     if ($this->db->engine == 'SQLite') {
         $res = "(title='my title' AND description='%par example' AND keywords='tag''gi`ng')";
         $res .= " OR (status='1')";
     } else {
         $res = "(title='my title' AND description='%par example' AND keywords='tag\\''gi`ng')";
         $res .= " OR (status='1')";
     }
     $this->assertEquals($res, $sql1->gen());
 }
예제 #20
0
파일: Tag.php 프로젝트: burbuja/indefero
 /**
  * Add a tag if not already existing.
  *
  * @param string Name of the tag.
  * @param IDF_Project Project of the tag.
  * @param string Class of the tag (IDF_TAG_DEFAULT_CLASS)
  * @return IDF_Tag The tag.
  */
 public static function add($name, $project, $class = IDF_TAG_DEFAULT_CLASS)
 {
     $class = trim($class);
     $name = trim($name);
     $gtag = new IDF_Tag();
     $sql = new Pluf_SQL('class=%s AND lcname=%s AND project=%s', array($class, mb_strtolower($name), $project->id));
     $tags = $gtag->getList(array('filter' => $sql->gen()));
     if ($tags->count() < 1) {
         // create a new tag
         $tag = new IDF_Tag();
         $tag->name = $name;
         $tag->class = $class;
         $tag->project = $project;
         $tag->create();
         return $tag;
     }
     return $tags[0];
 }
예제 #21
0
 /**
  * Just a simple control.
  */
 public function clean_key()
 {
     $this->cleaned_data['key'] = trim($this->cleaned_data['key']);
     $error = __('We are sorry but this confirmation key is not valid. Maybe you should directly copy/paste it from your confirmation email.');
     if (false === ($email_id = IDF_Form_RegisterInputKey::checkKeyHash($this->cleaned_data['key']))) {
         throw new Pluf_Form_Invalid($error);
     }
     $guser = new Pluf_User();
     $sql = new Pluf_SQL('email=%s AND id=%s', $email_id);
     $users = $guser->getList(array('filter' => $sql->gen()));
     if ($users->count() != 1) {
         throw new Pluf_Form_Invalid($error);
     }
     if ($users[0]->active) {
         throw new Pluf_Form_Invalid(__('This account has already been confirmed. Maybe should you try to recover your password using the help link.'));
     }
     $this->_user_id = $email_id[1];
     return $this->cleaned_data['key'];
 }
예제 #22
0
파일: Commit.php 프로젝트: Br3nda/indefero
 /**
  * Create a commit from a simple class commit info of a changelog.
  *
  * @param stdClass Commit info
  * @param IDF_Project Current project
  * @return IDF_Commit
  */
 public static function getOrAdd($change, $project)
 {
     $sql = new Pluf_SQL('project=%s AND scm_id=%s', array($project->id, $change->commit));
     $r = Pluf::factory('IDF_Commit')->getList(array('filter' => $sql->gen()));
     if ($r->count() > 0) {
         return $r[0];
     }
     if (!isset($change->full_message)) {
         $change->full_message = '';
     }
     $scm = IDF_Scm::get($project);
     $commit = new IDF_Commit();
     $commit->project = $project;
     $commit->scm_id = $change->commit;
     $commit->summary = self::toUTF8($change->title);
     $commit->fullmessage = self::toUTF8($change->full_message);
     $commit->author = $scm->findAuthor($change->author);
     $commit->origauthor = $change->author;
     $commit->creation_dtime = $change->date;
     $commit->create();
     $commit->notify($project->getConf());
     return $commit;
 }
예제 #23
0
 public function timelineFeed($request, $match)
 {
     $prj = $request->project;
     $model_filter = @$match[2];
     $model_filter = @$match[2];
     $all_model_filters = self::getAvailableModelFilters();
     if (!array_key_exists($model_filter, $all_model_filters)) {
         $model_filter = 'all';
     }
     $title = $all_model_filters[$model_filter];
     $classes = self::determineModelClasses($request, $model_filter);
     $sqls = sprintf('model_class IN (%s)', implode(', ', $classes));
     $sql = new Pluf_SQL('project=%s AND ' . $sqls, array($prj->id));
     $params = array('filter' => $sql->gen(), 'order' => 'creation_dtime DESC', 'nb' => 20);
     $items = Pluf::factory('IDF_Timeline')->getList($params);
     $set = new Pluf_Model_Set($items, array('public_dtime' => 'public_dtime'));
     $out = array();
     foreach ($set as $item) {
         if ($item->id) {
             $out[] = $item->feedFragment($request);
         }
     }
     if ($items->count() > 0) {
         $date = Pluf_Date::gmDateToGmString($items[0]->creation_dtime);
     } else {
         $date = gmdate('c');
     }
     $out = Pluf_Template::markSafe(implode("\n", $out));
     $tmpl = new Pluf_Template('idf/index.atom');
     $feedurl = Pluf::f('url_base') . Pluf::f('idf_base') . $request->query;
     $viewurl = Pluf_HTTP_URL_urlForView('IDF_Views_Project::timeline', array($prj->shortname));
     $context = new Pluf_Template_Context_Request($request, array('body' => $out, 'date' => $date, 'title' => $title, 'feedurl' => $feedurl, 'viewurl' => $viewurl));
     return new Pluf_HTTP_Response('<?xml version="1.0" encoding="utf-8"?>' . "\n" . $tmpl->render($context), 'application/atom+xml; charset=utf-8');
 }
예제 #24
0
 public function clean_login()
 {
     $this->cleaned_data['login'] = mb_strtolower(trim($this->cleaned_data['login']));
     if (preg_match('/[^a-z0-9]/', $this->cleaned_data['login'])) {
         throw new Pluf_Form_Invalid(sprintf(__('The login "%s" can only contain letters and digits.'), $this->cleaned_data['login']));
     }
     $guser = new Pluf_User();
     $sql = new Pluf_SQL('login=%s', $this->cleaned_data['login']);
     if ($guser->getCount(array('filter' => $sql->gen())) > 0) {
         throw new Pluf_Form_Invalid(sprintf(__('The login "%s" is already used, please find another one.'), $this->cleaned_data['login']));
     }
     return $this->cleaned_data['login'];
 }
예제 #25
0
파일: Git.php 프로젝트: burbuja/indefero
 /**
  * Given the string describing the author from the log find the
  * author in the database.
  *
  * @param string Author
  * @return mixed Pluf_User or null
  */
 public function findAuthor($author)
 {
     // We extract the email.
     $match = array();
     if (!preg_match('/<(.*)>/', $author, $match)) {
         return null;
     }
     foreach (array('email', 'login') as $what) {
         $sql = new Pluf_SQL($what . '=%s', array($match[1]));
         $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
         if ($users->count() > 0) {
             return $users[0];
         }
     }
     return null;
 }
예제 #26
0
 /**
  * The update of the memberships is done in different places. This
  * avoids duplicating code.
  *
  * @param IDF_Project The project
  * @param array The new memberships data in 'owners' and 'members' keys
  */
 public static function updateMemberships($project, $cleaned_data)
 {
     // remove all the permissions
     $cm = $project->getMembershipData();
     $def = array('owners' => Pluf_Permission::getFromString('IDF.project-owner'), 'members' => Pluf_Permission::getFromString('IDF.project-member'));
     $guser = new Pluf_User();
     foreach ($def as $key => $perm) {
         foreach ($cm[$key] as $user) {
             Pluf_RowPermission::remove($user, $project, $perm);
         }
         foreach (preg_split("/\r\n|\r|\n|\\,/", $cleaned_data[$key], -1, PREG_SPLIT_NO_EMPTY) as $login) {
             $sql = new Pluf_SQL('login=%s', array(trim($login)));
             $users = $guser->getList(array('filter' => $sql->gen()));
             if ($users->count() == 1) {
                 Pluf_RowPermission::add($users[0], $project, $perm);
             }
         }
     }
 }
예제 #27
0
파일: Issue.php 프로젝트: Br3nda/indefero
 public function myIssues($request, $match)
 {
     $prj = $request->project;
     $otags = $prj->getTagIdsByStatus('open');
     $ctags = $prj->getTagIdsByStatus('closed');
     if (count($otags) == 0) {
         $otags[] = 0;
     }
     if (count($ctags) == 0) {
         $ctags[] = 0;
     }
     switch ($match[2]) {
         case 'submit':
             $title = sprintf(__('My Submitted %s Issues'), (string) $prj);
             $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN (' . implode(', ', $otags) . ')', array($prj->id, $request->user->id));
             break;
         case 'submitclosed':
             $title = sprintf(__('My Closed Submitted %s Issues'), (string) $prj);
             $f_sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN (' . implode(', ', $ctags) . ')', array($prj->id, $request->user->id));
             break;
         case 'ownerclosed':
             $title = sprintf(__('My Closed Working %s Issues'), (string) $prj);
             $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN (' . implode(', ', $ctags) . ')', array($prj->id, $request->user->id));
             break;
         default:
             $title = sprintf(__('My Working %s Issues'), (string) $prj);
             $f_sql = new Pluf_SQL('project=%s AND owner=%s AND status IN (' . implode(', ', $otags) . ')', array($prj->id, $request->user->id));
             break;
     }
     // Get stats about the issues
     $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN (' . implode(', ', $otags) . ')', array($prj->id, $request->user->id));
     $nb_submit = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN (' . implode(', ', $otags) . ')', array($prj->id, $request->user->id));
     $nb_owner = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     // Closed issues
     $sql = new Pluf_SQL('project=%s AND submitter=%s AND status IN (' . implode(', ', $ctags) . ')', array($prj->id, $request->user->id));
     $nb_submit_closed = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     $sql = new Pluf_SQL('project=%s AND owner=%s AND status IN (' . implode(', ', $ctags) . ')', array($prj->id, $request->user->id));
     $nb_owner_closed = Pluf::factory('IDF_Issue')->getCount(array('filter' => $sql->gen()));
     // Paginator to paginate the issues
     $pag = new Pluf_Paginator(new IDF_Issue());
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('project_m' => $prj, 'shortname' => $prj->shortname, 'current_user' => $request->user);
     $pag->summary = __('This table shows the open issues.');
     $pag->forced_where = $f_sql;
     $pag->action = array('IDF_Views_Issue::myIssues', array($prj->shortname, $match[2]));
     $pag->sort_order = array('modif_dtime', 'ASC');
     // will be reverted
     $pag->sort_reverse_order = array('modif_dtime');
     $pag->sort_link_title = true;
     $pag->extra_classes = array('a-c', '', 'a-c', '');
     $list_display = array('id' => __('Id'), array('summary', 'IDF_Views_Issue_SummaryAndLabels', __('Summary')), array('status', 'IDF_Views_Issue_ShowStatus', __('Status')), array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')));
     $pag->configure($list_display, array(), array('id', 'status', 'modif_dtime'));
     $pag->items_per_page = 10;
     $pag->no_results_text = __('No issues were found.');
     $pag->setFromRequest($request);
     return Pluf_Shortcuts_RenderToResponse('idf/issues/my-issues.html', array('project' => $prj, 'page_title' => $title, 'nb_submit' => $nb_submit, 'nb_owner' => $nb_owner, 'nb_submit_closed' => $nb_submit_closed, 'nb_owner_closed' => $nb_owner_closed, 'issues' => $pag), $request);
 }
예제 #28
0
 function clean_email()
 {
     $email = mb_strtolower(trim($this->cleaned_data['email']));
     $sql = new Pluf_SQL('email=%s AND id!=%s', array($email, $this->user->id));
     $users = Pluf::factory('Pluf_User')->getList(array('filter' => $sql->gen()));
     if ($users->count() > 0) {
         throw new Pluf_Form_Invalid(__('A user with this email already exists, please provide another email address.'));
     }
     return $email;
 }
예제 #29
0
파일: User.php 프로젝트: burbuja/pluf
 /**
  * Get profile.
  *
  * Retrieve the profile of the current user. If not profile in the
  * database a Pluf_Exception_DoesNotExist exception is thrown,
  * just catch it and create a profile.
  *
  * @return Pluf_Model User profile
  */
 function getProfile()
 {
     $pclass = Pluf::f('user_profile_class', false);
     if (false == $pclass) {
         throw new Pluf_Exception_SettingError(__('"user_profile_class" setting not defined.'));
     }
     $db = $this->getDbConnection();
     $sql = new Pluf_SQL(sprintf('%s=%%s', $db->qn('user')), array($this->id));
     $users = Pluf::factory($pclass)->getList(array('filter' => $sql->gen()));
     if ($users->count() != 1) {
         throw new Pluf_Exception_DoesNotExist(sprintf(__('No profiles available for user: %s'), (string) $this));
     }
     return $users[0];
 }
예제 #30
0
파일: Project.php 프로젝트: Br3nda/indefero
 public function timelineFeed($request, $match)
 {
     $prj = $request->project;
     // Need to check the rights
     $rights = array();
     if (true === IDF_Precondition::accessSource($request)) {
         $rights[] = '\'IDF_Commit\'';
         IDF_Scm::syncTimeline($request->project);
     }
     if (true === IDF_Precondition::accessIssues($request)) {
         $rights[] = '\'IDF_Issue\'';
         $rights[] = '\'IDF_IssueComment\'';
     }
     if (true === IDF_Precondition::accessDownloads($request)) {
         $rights[] = '\'IDF_Upload\'';
     }
     if (true === IDF_Precondition::accessWiki($request)) {
         $rights[] = '\'IDF_WikiPage\'';
         $rights[] = '\'IDF_WikiRevision\'';
     }
     if (true === IDF_Precondition::accessReview($request)) {
         $rights[] = '\'IDF_Review_Comment\'';
         $rights[] = '\'IDF_Review_Patch\'';
     }
     if (count($rights) == 0) {
         $rights[] = '\'IDF_Dummy\'';
     }
     $sqls = sprintf('model_class IN (%s)', implode(', ', $rights));
     $sql = new Pluf_SQL('project=%s AND ' . $sqls, array($prj->id));
     $params = array('filter' => $sql->gen(), 'order' => 'creation_dtime DESC', 'nb' => 20);
     $items = Pluf::factory('IDF_Timeline')->getList($params);
     $set = new Pluf_Model_Set($items, array('public_dtime' => 'public_dtime'));
     $out = array();
     foreach ($set as $item) {
         if ($item->id) {
             $out[] = $item->feedFragment($request);
         }
     }
     if ($items->count() > 0) {
         $date = Pluf_Date::gmDateToGmString($items[0]->creation_dtime);
     } else {
         $date = gmdate('c');
     }
     $out = Pluf_Template::markSafe(implode("\n", $out));
     $tmpl = new Pluf_Template('idf/index.atom');
     $title = __('Updates');
     $feedurl = Pluf::f('url_base') . Pluf::f('idf_base') . $request->query;
     $viewurl = Pluf_HTTP_URL_urlForView('IDF_Views_Project::timeline', array($prj->shortname));
     $context = new Pluf_Template_Context_Request($request, array('body' => $out, 'date' => $date, 'title' => $title, 'feedurl' => $feedurl, 'viewurl' => $viewurl));
     return new Pluf_HTTP_Response('<?xml version="1.0" encoding="utf-8"?>' . "\n" . $tmpl->render($context), 'application/atom+xml; charset=utf-8');
 }