コード例 #1
0
ファイル: RegisterInputKey.php プロジェクト: burbuja/indefero
 /**
  * Save the model in the database.
  *
  * @param bool Commit in the database or not. If not, the object
  *             is returned but not saved in the database.
  * @return string Url to redirect to the form.
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save an invalid form.'));
     }
     return Pluf_HTTP_URL_urlForView('IDF_Views::registerConfirmation', array($this->cleaned_data['key']));
 }
コード例 #2
0
ファイル: UserChangeEmail.php プロジェクト: burbuja/indefero
 /**
  * Save the model in the database.
  *
  * @param bool Commit in the database or not. If not, the object
  *             is returned but not saved in the database.
  * @return Object Model with data set from the form.
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     return Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailDo', array($this->cleaned_data['key']));
 }
コード例 #3
0
ファイル: SourceConf.php プロジェクト: burbuja/indefero
 public function initFields($extra = array())
 {
     $this->conf = $extra['conf'];
     if ($extra['remote_svn']) {
         $this->fields['svn_username'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Repository username'), 'initial' => $this->conf->getVal('svn_username', ''), 'widget_attrs' => array('size' => '15')));
         $this->fields['svn_password'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Repository password'), 'initial' => $this->conf->getVal('svn_password', ''), 'widget' => 'Pluf_Form_Widget_PasswordInput'));
     }
     Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
     $url = Pluf_HTTP_URL_urlForView('idf_faq') . '#webhooks';
     $this->fields['webhook_url'] = new Pluf_Form_Field_Url(array('required' => false, 'label' => __('Webhook URL'), 'initial' => $this->conf->getVal('webhook_url', ''), 'help_text' => sprintf(__('Learn more about the <a href="%s">post-commit web hooks</a>.'), $url), 'widget_attrs' => array('size' => 35)));
 }
コード例 #4
0
ファイル: Comment.php プロジェクト: Br3nda/indefero
 public function feedFragment($request)
 {
     $review = $this->get_patch()->get_review();
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($request->project->shortname, $review->id));
     $title = sprintf(__('%s: Updated review %d - %s'), Pluf_esc($request->project->name), $review->id, Pluf_esc($review->summary));
     $url .= '#ic' . $this->id;
     $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
     $context = new Pluf_Template_Context_Request($request, array('url' => $url, 'author' => $this->get_submitter(), 'title' => $title, 'c' => $this, 'review' => $review, 'date' => $date));
     $tmpl = new Pluf_Template('idf/review/feedfragment.xml');
     return $tmpl->render($context);
 }
コード例 #5
0
ファイル: Markdown.php プロジェクト: burbuja/indefero
 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>';
 }
コード例 #6
0
ファイル: RedirectToLogin.php プロジェクト: burbuja/pluf
 /**
  * The $request object is used to know what the post login
  * redirect url should be.
  *
  * If the action url of the login page is not set, it will try to
  * get the url from the login view from the 'login_view'
  * configuration key.
  *
  * @param Pluf_HTTP_Request The request object of the current page.
  * @param string The full url of the login page (null)
  */
 function __construct($request, $loginurl = null)
 {
     if ($loginurl !== null) {
         $murl = new Pluf_HTTP_URL();
         $url = $murl->generate($loginurl, array('_redirect_after' => $request->uri), false);
         $encoded = $murl->generate($loginurl, array('_redirect_after' => $request->uri));
     } else {
         Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
         $url = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri), false);
         $encoded = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri));
     }
     $content = sprintf(__('<a href="%s">Please, click here to be redirected</a>.'), $encoded);
     parent::__construct($content);
     $this->headers['Location'] = $url;
     $this->status_code = 302;
 }
コード例 #7
0
ファイル: Svn.php プロジェクト: burbuja/indefero
 /**
  * Display SVN changelog from specific revision
  *
  */
 public function changelogRev($request, $match)
 {
     $prj = $request->project;
     if ($request->conf->getVal('scm', 'git') != 'svn') {
         // Redirect to tree base if not svn
         $scmRoot = $prj->getScmRoot();
     } else {
         // Get revision value if svn
         if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
             $scmRoot = $prj->getScmRoot();
         } else {
             $scmRoot = $request->REQUEST['rev'];
         }
     }
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::changeLog', array($prj->shortname, $scmRoot));
     return new Pluf_HTTP_Response_Redirect($url);
 }
コード例 #8
0
ファイル: Precondition.php プロジェクト: burbuja/indefero
 /**
  * Validates the revision given in the URL path and acts accordingly
  *
  * @param $request
  * @return true | Pluf_HTTP_Response_Redirect
  * @throws Exception
  */
 public static function revisionValid($request)
 {
     list($url_info, $url_matches) = $request->view;
     list(, $project, $commit) = $url_matches;
     $scm = IDF_Scm::get($request->project);
     $res = $scm->validateRevision($commit);
     switch ($res) {
         case IDF_Scm::REVISION_VALID:
             return true;
         case IDF_Scm::REVISION_INVALID:
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::invalidRevision', array($request->project->shortname, $commit));
             return new Pluf_HTTP_Response_Redirect($url);
         case IDF_Scm::REVISION_AMBIGUOUS:
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::disambiguateRevision', array($request->project->shortname, $commit, $url_info['model'] . '::' . $url_info['method']));
             return new Pluf_HTTP_Response_Redirect($url);
         default:
             throw new Exception('unknown validation result: ' . $res);
     }
 }
コード例 #9
0
ファイル: ShowUser.php プロジェクト: burbuja/indefero
 /**
  * We need the user object and the request.
  *
  * If the user object is null (for example a non associated
  * commit), we can use the $text value for an alternative display.
  *
  * @param Pluf_User
  * @param Pluf_HTTP_Request
  * @param string Alternate text ('')
  */
 function start($user, $request, $text = '', $echo = true)
 {
     if ($user == null) {
         $out = strlen($text) ? strip_tags($text) : __('Anonymous');
     } else {
         if (!$user->isAnonymous() and $user->id == $request->user->id) {
             $utext = __('Me');
             $url = Pluf_HTTP_URL_urlForView('idf_dashboard');
         } else {
             $utext = Pluf_esc($user);
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_User::view', array($user->login));
         }
         $out = sprintf('<a href="%s" class="username">%s</a>', $url, $utext);
     }
     if ($echo) {
         echo $out;
     } else {
         return $out;
     }
 }
コード例 #10
0
ファイル: Url.php プロジェクト: burbuja/pluf
 function start($view, $params = array(), $get_params = array())
 {
     echo Pluf_HTTP_URL_urlForView($view, $params, $get_params);
 }
コード例 #11
0
ファイル: Source.php プロジェクト: Br3nda/indefero
 public function download($request, $match)
 {
     $commit = trim($match[2]);
     $scm = IDF_Scm::get($request->project);
     if (!$scm->isValidRevision($commit)) {
         // Redirect to the first branch
         $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase', array($request->project->shortname, $scm->getMainBranch()));
         return new Pluf_HTTP_Response_Redirect($url);
     }
     $base = $request->project->shortname . '-' . $commit;
     $cmd = $scm->getArchiveCommand($commit, $base . '/');
     $rep = new Pluf_HTTP_Response_CommandPassThru($cmd, 'application/x-zip');
     $rep->headers['Content-Transfer-Encoding'] = 'binary';
     $rep->headers['Content-Disposition'] = 'attachment; filename="' . $base . '.zip"';
     return $rep;
 }
コード例 #12
0
ファイル: Issue.php プロジェクト: Br3nda/indefero
 public function feedFragment($request)
 {
     $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', array($request->project->shortname, $this->id));
     $title = sprintf(__('%s: Issue %d created - %s'), $request->project->name, $this->id, $this->summary);
     $cts = $this->get_comments_list(array('order' => 'id ASC', 'nb' => 1));
     $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
     $context = new Pluf_Template_Context_Request($request, array('url' => $url, 'author' => $this->get_submitter(), 'title' => $title, 'c' => $cts[0], 'issue' => $this, 'date' => $date));
     $tmpl = new Pluf_Template('idf/issues/feedfragment.xml');
     return $tmpl->render($context);
 }
コード例 #13
0
ファイル: Issue.php プロジェクト: Br3nda/indefero
 public function star($request, $match)
 {
     $prj = $request->project;
     $issue = Pluf_Shortcuts_GetObjectOr404('IDF_Issue', $match[2]);
     $prj->inOr404($issue);
     if ($request->method == 'POST') {
         $starred = Pluf_Model_InArray($request->user, $issue->get_interested_list());
         if ($starred) {
             $issue->delAssoc($request->user);
             $request->user->setMessage(__('The issue has been removed from your watch list.'));
         } else {
             $issue->setAssoc($request->user);
             $request->user->setMessage(__('The issue has been added to your watch list.'));
         }
     }
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', array($prj->shortname, $issue->id));
     return new Pluf_HTTP_Response_Redirect($url);
 }
コード例 #14
0
ファイル: Views.php プロジェクト: burbuja/pluf
 /**
  * Delete an object (Part of the CRUD series).
  *
  * The minimal extra parameter is the model class name. The list
  * of extra parameters is:
  *
  * 'model' - Class name string, required.
  *
  * 'post_delete_redirect' - View to redirect after saving, required.
  *
  * 'id' - Index in the match to fin the id of the object to delete (1)
  * 
  * 'login_required' - Do we require login (false)
  *
  * 'template' - Template to use ('"model class"_confirm_delete.html')
  *
  * 'post_delete_redirect_keys' - Which keys of the model to pass to
  *                             the view (array())
  *
  * 'extra_context' - Array of key/values to be added to the
  *                   context (array())
  * 
  * @param Pluf_HTTP_Request Request object
  * @param array Match
  * @param array Extra parameters
  * @return Pluf_HTTP_Response Response object (can be a redirect)
  */
 public function deleteObject($request, $match, $p)
 {
     if (isset($p['login_required']) && true == $p['login_required']) {
         if ($request->user->isAnonymous()) {
             return new Pluf_HTTP_Response_RedirectToLogin($request);
         }
     }
     if (!isset($p['model'])) {
         throw new Exception('The model class was not provided in the parameters.');
     }
     // Set the default
     $id = isset($p['id']) ? $match[$p['id']] : $match[1];
     $model = $p['model'];
     $context = isset($p['extra_context']) ? $p['extra_context'] : array();
     $template = isset($p['template']) ? $p['template'] : strtolower($model) . '_confirm_delete.html';
     $post_delete_keys = isset($p['post_delete_redirect_keys']) ? $p['post_delete_redirect_keys'] : array();
     $object = Pluf_Shortcuts_GetObjectOr404($model, $id);
     if ($request->method == 'POST') {
         $object->delete();
         if (isset($p['post_delete_redirect'])) {
             $url = Pluf_HTTP_URL_urlForView($p['post_delete_redirect'], $post_delete_keys);
         } else {
             throw new Exception('No URL to redirect to from generic delete view.');
         }
         if (!$request->user->isAnonymous()) {
             $request->user->setMessage(sprintf(__('The %s was deleted successfully.'), $object->_a['verbose']));
         }
         return new Pluf_HTTP_Response_Redirect($url);
     }
     return Pluf_Shortcuts_RenderToResponse($template, array_merge($context, array('object' => $object)), $request);
 }
コード例 #15
0
ファイル: Admin.php プロジェクト: Br3nda/indefero
 public function userCreate($request, $match)
 {
     $params = array('request' => $request);
     if ($request->method == 'POST') {
         $form = new IDF_Form_Admin_UserCreate($request->POST, $params);
         if ($form->isValid()) {
             $cuser = $form->save();
             $request->user->setMessage(sprintf(__('The user %s has been created.'), (string) $cuser));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::users');
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_Admin_UserCreate(null, $params);
     }
     $title = __('Add User');
     return Pluf_Shortcuts_RenderToResponse('idf/gadmin/users/create.html', array('page_title' => $title, 'form' => $form), $request);
 }
コード例 #16
0
ファイル: Project.php プロジェクト: burbuja/indefero
 public function adminSource($request, $match)
 {
     $prj = $request->project;
     $title = sprintf(__('%s Source'), (string) $prj);
     $remote_svn = ($request->conf->getVal('scm') == 'svn' and strlen($request->conf->getVal('svn_remote_url')) > 0);
     $extra = array('conf' => $request->conf, 'remote_svn' => $remote_svn);
     if ($request->method == 'POST') {
         $form = new IDF_Form_SourceConf($request->POST, $extra);
         if ($form->isValid()) {
             foreach ($form->cleaned_data as $key => $val) {
                 $request->conf->setVal($key, $val);
             }
             $request->user->setMessage(__('The project source configuration  has been saved.'));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminSource', array($prj->shortname));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $params = array();
         foreach (array('svn_username', 'svn_password', 'webhook_url') as $key) {
             $_val = $request->conf->getVal($key, false);
             if ($_val !== false) {
                 $params[$key] = $_val;
             }
         }
         if (count($params) == 0) {
             $params = null;
             //Nothing in the db, so new form.
         }
         $form = new IDF_Form_SourceConf($params, $extra);
     }
     $scm = $request->conf->getVal('scm', 'git');
     $options = array('git' => __('git'), 'svn' => __('Subversion'), 'mercurial' => __('mercurial'), 'mtn' => __('monotone'));
     $repository_type = $options[$scm];
     return Pluf_Shortcuts_RenderToResponse('idf/admin/source.html', array('remote_svn' => $remote_svn, 'repository_access' => $prj->getRemoteAccessUrl(), 'repository_type' => $repository_type, 'repository_size' => $prj->getRepositorySize(), 'page_title' => $title, 'form' => $form, 'hookkey' => $prj->getPostCommitHookKey()), $request);
 }
コード例 #17
0
ファイル: Admin.php プロジェクト: burbuja/indefero
 public function usherServerConnections($request, $match)
 {
     $server = $match[1];
     if (!in_array($server, IDF_Scm_Monotone_Usher::getServerList())) {
         throw new Pluf_HTTP_Error404();
     }
     $title = sprintf(__('Open connections for "%s"'), $server);
     $connections = IDF_Scm_Monotone_Usher::getConnectionList($server);
     if (count($connections) == 0) {
         $request->user->setMessage(sprintf(__('no connections for server "%s"'), $server));
         $url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::usher');
         return new Pluf_HTTP_Response_Redirect($url);
     }
     return Pluf_Shortcuts_RenderToResponse('idf/gadmin/usher/connections.html', array('page_title' => $title, 'server' => $server, 'connections' => $connections), $request);
 }
コード例 #18
0
ファイル: Views.php プロジェクト: burbuja/pluf
 public function funnels($request, $match)
 {
     $url = Pluf_HTTP_URL_urlForView('pluf_ab_funnels');
     $funnels = Pluf_AB_Funnel::getFunnels();
     return Pluf_Shortcuts_RenderToResponse('pluf/ab/funnels.html', array('funnels' => $funnels), $request);
 }
コード例 #19
0
ファイル: Views.php プロジェクト: burbuja/pluf
 /**
  * Display the addList page of the application.
  *
  * @param Pluf_HTTP_Request Request object
  * @param array Matches against the regex of the dispatcher
  * @return Pluf_HTTP_Response or can throw Exception
  */
 public function addList($request, $match)
 {
     // The workflow of the addition of an item is simple
     // If the request of GET method a form is displayed
     // If it is a POST method, the form is submitted and the
     // content is proceeded to create the new list.
     // We create a Todo_List item as we are creating one here
     $list = new Todo_List();
     if ($request->method == 'POST') {
         // We create the form bounded to the data submitted.
         $form = new Todo_Form_List($request->POST);
         if ($form->isValid()) {
             // If no errors, we can save the Todo_List from the data
             $list->setFromFormData($form->cleaned_data);
             $list->create();
             // We redirect the user to the page of the Todo_List
             $url = Pluf_HTTP_URL_urlForView('Todo_Views::viewList', array($list->id));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new Todo_Form_List();
     }
     return Pluf_Shortcuts_RenderToResponse('todo/list/add.html', array('page_title' => 'Add a Todo List', 'form' => $form));
 }
コード例 #20
0
ファイル: Upload.php プロジェクト: burbuja/indefero
 public function feedFragment($request)
 {
     $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_Download::view', array($request->project->shortname, $this->id));
     $title = sprintf(__('%s: Download %d added - %s'), $request->project->name, $this->id, $this->summary);
     $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
     $context = new Pluf_Template_Context_Request($request, array('url' => $url, 'title' => $title, 'file' => $this, 'date' => $date));
     $tmpl = new Pluf_Template('idf/downloads/feedfragment.xml');
     return $tmpl->render($context);
 }
コード例 #21
0
ファイル: UserAccount.php プロジェクト: Br3nda/indefero
 /**
  * Save the model in the database.
  *
  * @param bool Commit in the database or not. If not, the object
  *             is returned but not saved in the database.
  * @return Object Model with data set from the form.
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     unset($this->cleaned_data['password2']);
     $update_pass = false;
     if (strlen($this->cleaned_data['password']) == 0) {
         unset($this->cleaned_data['password']);
     } else {
         $update_pass = true;
     }
     $old_email = $this->user->email;
     $new_email = $this->cleaned_data['email'];
     unset($this->cleaned_data['email']);
     if ($old_email != $new_email) {
         $cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
         $encrypted = trim($cr->encrypt($new_email . ':' . $this->user->id . ':' . time()), '~');
         $key = substr(md5(Pluf::f('secret_key') . $encrypted), 0, 2) . $encrypted;
         $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailDo', array($key), array(), false);
         $urlik = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailInputKey', array(), array(), false);
         $context = new Pluf_Template_Context(array('key' => Pluf_Template::markSafe($key), 'url' => Pluf_Template::markSafe($url), 'urlik' => Pluf_Template::markSafe($urlik), 'email' => $new_email, 'user' => $this->user));
         $tmpl = new Pluf_Template('idf/user/changeemail-email.txt');
         $text_email = $tmpl->render($context);
         $email = new Pluf_Mail(Pluf::f('from_email'), $new_email, __('Confirm your new email address.'));
         $email->addTextMessage($text_email);
         $email->sendMail();
         $this->user->setMessage(sprintf(__('A validation email has been sent to "%s" to validate the email address change.'), Pluf_esc($new_email)));
     }
     $this->user->setFromFormData($this->cleaned_data);
     // Add key as needed.
     if ('' !== $this->cleaned_data['ssh_key']) {
         $key = new IDF_Key();
         $key->user = $this->user;
         $key->content = $this->cleaned_data['ssh_key'];
         if ($commit) {
             $key->create();
         }
     }
     if ($commit) {
         $this->user->update();
         if ($update_pass) {
             /**
              * [signal]
              *
              * Pluf_User::passwordUpdated
              *
              * [sender]
              *
              * IDF_Form_UserAccount
              *
              * [description]
              *
              * This signal is sent when the user updated his
              * password from his account page.
              *
              * [parameters]
              *
              * array('user' => $user)
              *
              */
             $params = array('user' => $this->user);
             Pluf_Signal::send('Pluf_User::passwordUpdated', 'IDF_Form_UserAccount', $params);
         }
     }
     return $this->user;
 }
コード例 #22
0
ファイル: Download.php プロジェクト: burbuja/indefero
 public function submit($request, $match)
 {
     $prj = $request->project;
     $title = __('New Download');
     if ($request->method == 'POST') {
         $form = new IDF_Form_Upload(array_merge($request->POST, $request->FILES), array('project' => $prj, 'user' => $request->user));
         if ($form->isValid()) {
             $upload = $form->save();
             $urlfile = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view', array($prj->shortname, $upload->id));
             $request->user->setMessage(sprintf(__('The <a href="%s">file</a> has been uploaded.'), $urlfile));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index', array($prj->shortname));
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_Upload(null, array('project' => $prj, 'user' => $request->user));
     }
     return Pluf_Shortcuts_RenderToResponse('idf/downloads/submit.html', array('auto_labels' => self::autoCompleteArrays($prj), 'page_title' => $title, 'form' => $form), $request);
 }
コード例 #23
0
ファイル: Commit.php プロジェクト: Br3nda/indefero
 /**
  * Returns the feed fragment for the commit.
  *
  * @param Pluf_HTTP_Request 
  * @return Pluf_Template_SafeString
  */
 public function feedFragment($request)
 {
     $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', array($request->project->shortname, $this->scm_id));
     $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
     $author = $this->get_author() ? $this->get_author() : $this->origauthor;
     $cproject = $this->get_project();
     $context = new Pluf_Template_Context_Request($request, array('c' => $this, 'cproject' => $cproject, 'url' => $url, 'date' => $date, 'author' => $author));
     $tmpl = new Pluf_Template('idf/source/feedfragment.xml');
     return $tmpl->render($context);
 }
コード例 #24
0
ファイル: WikiPage.php プロジェクト: burbuja/indefero
 public function feedFragment($request)
 {
     $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', array($request->project->shortname, $this->title));
     $title = sprintf(__('%s: Documentation page %s added - %s'), $request->project->name, $this->title, $this->summary);
     $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
     $context = new Pluf_Template_Context_Request($request, array('url' => $url, 'title' => $title, 'page' => $this, 'rev' => $this->get_current_revision(), 'create' => true, 'date' => $date));
     $tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
     return $tmpl->render($context);
 }
コード例 #25
0
ファイル: UserCreate.php プロジェクト: burbuja/indefero
 /**
  * Save the model in the database.
  *
  * @param bool Commit in the database or not. If not, the object
  *             is returned but not saved in the database.
  * @return Object Model with data set from the form.
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     $password = Pluf_Utils::getPassword();
     $user = new Pluf_User();
     $user->setFromFormData($this->cleaned_data);
     $user->active = true;
     $user->staff = false;
     $user->administrator = false;
     $user->setPassword($password);
     $user->create();
     /**
      * [signal]
      *
      * Pluf_User::passwordUpdated
      *
      * [sender]
      *
      * IDF_Form_Admin_UserCreate
      *
      * [description]
      *
      * This signal is sent when a user is created
      * by the staff.
      *
      * [parameters]
      *
      * array('user' => $user)
      *
      */
     $params = array('user' => $user);
     Pluf_Signal::send('Pluf_User::passwordUpdated', 'IDF_Form_Admin_UserCreate', $params);
     // Create the public key as needed
     if ('' !== $this->cleaned_data['public_key']) {
         $key = new IDF_Key();
         $key->user = $user;
         $key->content = $this->cleaned_data['public_key'];
         $key->create();
     }
     // Send an email to the user with the password
     Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
     $url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views::login', array(), array(), false);
     $context = new Pluf_Template_Context(array('password' => Pluf_Template::markSafe($password), 'user' => $user, 'url' => Pluf_Template::markSafe($url), 'admin' => $this->request->user));
     $tmpl = new Pluf_Template('idf/gadmin/users/createuser-email.txt');
     $text_email = $tmpl->render($context);
     $email = new Pluf_Mail(Pluf::f('from_email'), $user->email, __('Your details to access your forge.'));
     $email->addTextMessage($text_email);
     $email->sendMail();
     return $user;
 }
コード例 #26
0
ファイル: Paginator.php プロジェクト: burbuja/pluf
 /**
  * Using $this->action and the $get_params array, generate the URL
  * with the data.
  *
  * @param array Get parameters (array()).
  * @param bool Encoded to be put in href="" (true).
  * @return string Url.
  */
 function getUrl($get_params = array(), $encoded = true)
 {
     // Default values
     $params = array();
     $by_name = false;
     $view = '';
     if (is_array($this->action)) {
         $view = $this->action[0];
         if (isset($this->action[1])) {
             $params = $this->action[1];
         }
     } else {
         $view = $this->action;
     }
     return Pluf_HTTP_URL_urlForView($view, $params, $get_params, $encoded);
 }
コード例 #27
0
ファイル: IssueComment.php プロジェクト: burbuja/indefero
 /**
  * Generate the link to a review.
  *
  * @param IDF_Review Review.
  * @param string Name of the link.
  * @return string Linked review.
  */
 public function linkReview($review, $title, $anchor = '')
 {
     $ic = in_array($review->status, $this->project->getTagIdsByStatus('closed')) ? 'issue-c' : 'issue-o';
     return '<a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($this->project->shortname, $review->id)) . $anchor . '" class="' . $ic . '" title="' . Pluf_esc($review->summary) . '">' . Pluf_esc($title) . '</a>';
 }
コード例 #28
0
ファイル: Review.php プロジェクト: burbuja/indefero
 public function view($request, $match)
 {
     $prj = $request->project;
     $review = Pluf_Shortcuts_GetObjectOr404('IDF_Review', $match[2]);
     $prj->inOr404($review);
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id));
     $title = Pluf_Template::markSafe(sprintf(__('Review <a href="%s">%d</a>: %s'), $url, $review->id, $review->summary));
     $patches = $review->get_patches_list();
     $patch = $patches[0];
     $diff = new IDF_Diff(file_get_contents(Pluf::f('upload_issue_path') . '/' . $patch->patch));
     $diff->parse();
     // The form to submit comments is based on the files in the
     // diff
     if ($request->method == 'POST' and !$request->user->isAnonymous()) {
         $form = new IDF_Form_ReviewFileComment($request->POST, array('files' => $diff->files, 'user' => $request->user, 'patch' => $patch, 'project' => $prj));
         if ($form->isValid()) {
             $review_comment = $form->save();
             $review = $patch->get_review();
             $urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($prj->shortname, $review->id));
             $request->user->setMessage(sprintf(__('Your <a href="%s">code review %d</a> has been published.'), $urlr, $review->id));
             $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index', array($prj->shortname));
             $review_comment->notify($request->conf);
             return new Pluf_HTTP_Response_Redirect($url);
         }
     } else {
         $form = new IDF_Form_ReviewFileComment(null, array('files' => $diff->files, 'user' => $request->user, 'project' => $prj, 'patch' => $patch));
     }
     $scm = IDF_Scm::get($request->project);
     $files = array();
     $reviewers = array();
     foreach ($diff->files as $filename => $def) {
         $fileinfo = $scm->getPathInfo($filename, $patch->get_commit()->scm_id);
         $sql = new Pluf_SQL('cfile=%s', array($filename));
         $cts = $patch->getFileComments(array('filter' => $sql->gen(), 'order' => 'creation_dtime ASC'));
         foreach ($cts as $ct) {
             $reviewers[] = $ct->get_comment()->get_submitter();
         }
         if (count($def['chunks'])) {
             $orig_file = $fileinfo ? $scm->getFile($fileinfo) : '';
             $files[$filename] = array($diff->fileCompare($orig_file, $def, $filename), $form->f->{md5($filename)}, $cts);
         } else {
             $files[$filename] = array('', $form->f->{md5($filename)}, $cts);
         }
     }
     $reviewers = Pluf_Model_RemoveDuplicates($reviewers);
     return Pluf_Shortcuts_RenderToResponse('idf/review/view.html', array_merge(array('page_title' => $title, 'review' => $review, 'files' => $files, 'diff' => $diff, 'patch' => $patch, 'comments' => $patch->get_comments_list(array('sort' => 'id ASC')), 'form' => $form, 'reviewers' => $reviewers), IDF_Views_Issue::autoCompleteArrays($prj)), $request);
 }
コード例 #29
0
ファイル: User.php プロジェクト: burbuja/indefero
 public function changeEmailDo($request, $match)
 {
     $key = $match[1];
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailInputKey');
     try {
         list($email, $id, $time) = IDF_Form_UserChangeEmail::validateKey($key);
     } catch (Pluf_Form_Invalid $e) {
         return new Pluf_HTTP_Response_Redirect($url);
     }
     if ($id != $request->user->id) {
         return new Pluf_HTTP_Response_Redirect($url);
     }
     // Now we have a change link coming from the right user.
     $request->user->email = $email;
     $request->user->update();
     $request->user->setMessage(sprintf(__('Your new email address "%s" has been validated. Thank you!'), Pluf_esc($email)));
     $url = Pluf_HTTP_URL_urlForView('IDF_Views_User::myAccount');
     return new Pluf_HTTP_Response_Redirect($url);
 }
コード例 #30
0
ファイル: Rurl.php プロジェクト: burbuja/pluf
 function start($var, $view, $params = array(), $get_params = array())
 {
     $this->context->set($var, Pluf_HTTP_URL_urlForView($view, $params, $get_params));
 }