Esempio n. 1
0
 function __construct($request, $vars = array())
 {
     $vars = array_merge(array('request' => $request), $vars);
     foreach (Pluf::f('template_context_processors', array()) as $proc) {
         Pluf::loadFunction($proc);
         $vars = array_merge($proc($request), $vars);
     }
     $params = array('request' => $request, 'context' => $vars);
     /**
      * [signal]
      *
      * Pluf_Template_Context_Request::construct
      *
      * [sender]
      *
      * Pluf_Template_Context_Request
      *
      * [description]
      *
      * This signal allows an application to dynamically modify the
      * context array.
      *
      * [parameters]
      *
      * array('request' => $request,
      *       'context' => array());
      *
      */
     Pluf_Signal::send('Pluf_Template_Context_Request::construct', 'Pluf_Template_Context_Request', $params);
     $this->_vars = new Pluf_Template_ContextVars($params['context']);
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 function __construct($label = false)
 {
     $label = $label ? $label : 'Test the `' . $this->tag_name . '` template tag.';
     parent::__construct($label);
     if (null === $this->tag_name) {
         throw new LogicException('You must initialize the `$tag_name` property.');
     }
     if (null === $this->tag_class) {
         throw new LogicException('You must initialize the `$tag_class` property.');
     }
     $folder = Pluf::f('tmp_folder') . '/templatetags';
     if (!file_exists($folder)) {
         mkdir($folder, 0777, true);
     }
     $this->tpl_folders = array($folder);
     Pluf_Signal::connect('Pluf_Template_Compiler::construct_template_tags_modifiers', array($this, 'addTemplatetag'));
 }
Esempio n. 4
0
 /**
  * The current item is going to be processed.
  */
 function processItem()
 {
     /**
      * [signal]
      *
      * IDF_Queue::processItem
      *
      * [sender]
      *
      * IDF_Queue
      *
      * [description]
      *
      * This signal allows an application to run an asynchronous
      * job. The handler gets the queue item and the results from
      * the previous run. If the handler key is not set, then the
      * job was not run. If set it can be either true (already done)
      * or false (error at last run).
      *
      * [parameters]
      *
      * array('item' => $item, 'res' => $res)
      *
      */
     $params = array('item' => $this, 'res' => $this->results);
     Pluf_Signal::send('IDF_Queue::processItem', 'IDF_Queue', $params);
     $this->status = 3;
     // Success
     foreach ($params['res'] as $handler => $ok) {
         if (!$ok) {
             $this->status = 2;
             // Set to need retry
             $this->trials += 1;
             break;
         }
     }
     $this->results = $params['res'];
     $this->lasttry_dtime = gmdate('Y-m-d H:i:s');
     $this->update();
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
     * @param string Encoded data
     * @return mixed Decoded data
     */
    public static function _decodeData($encoded_data)
    {
        $check = substr($encoded_data, -32);
        $base64_data = substr($encoded_data, 0, strlen($encoded_data) - 32);
        if (md5($base64_data . Pluf::f('secret_key')) != $check) {
            throw new Exception('The session data may have been tampered.');
        }
        return unserialize(base64_decode($base64_data));
    }
    public static function processContext($signal, &$params)
    {
        $params['context'] = array_merge($params['context'], Pluf_Middleware_Session_ContextPreProcessor($params['request']));
    }
}
/**
 * Context preprocessor.
 *
 * Set the $user key.
 *
 * @param Pluf_HTTP_Request Request object
 * @return array Array to merge with the context
 */
function Pluf_Middleware_Session_ContextPreProcessor($request)
{
    return array('user' => $request->user);
}
Pluf_Signal::connect('Pluf_Template_Context_Request::construct', array('Pluf_Middleware_Session', 'processContext'));
Esempio n. 7
0
 /**
  * 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['public_key']) {
         $key = new IDF_Key();
         $key->user = $this->user;
         $key->content = $this->cleaned_data['public_key'];
         if ($commit) {
             $key->create();
         }
     }
     if ($commit) {
         $this->user->update();
         // FIXME: go the extra mile and check the input lengths for
         // all fields here!
         // FIXME: this is all doubled in admin/UserUpdate!
         $user_data = IDF_UserData::factory($this->user);
         // Add or remove avatar - we need to do this here because every
         // single setter directly leads to a save in the database
         if ($user_data->avatar != '' && ($this->cleaned_data['remove_custom_avatar'] == 1 || $this->cleaned_data['custom_avatar'] != '')) {
             $avatar_path = Pluf::f('upload_path') . '/avatars/' . basename($user_data->avatar);
             if (basename($avatar_path) != '' && is_file($avatar_path)) {
                 unlink($avatar_path);
             }
             $user_data->avatar = '';
         }
         if ($this->cleaned_data['custom_avatar'] != '') {
             $user_data->avatar = $this->cleaned_data['custom_avatar'];
         }
         $user_data->description = $this->cleaned_data['description'];
         $user_data->twitter = $this->cleaned_data['twitter'];
         $user_data->public_email = $this->cleaned_data['public_email'];
         $user_data->website = $this->cleaned_data['website'];
         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;
 }
Esempio n. 8
0
Pluf_Signal::connect('Pluf_Template_Compiler::construct_template_tags_modifiers', array('IDF_Middleware', 'updateTemplateTagsModifiers'));
# -- Standard plugins, they will run only if configured --
#
# Subversion synchronization
Pluf_Signal::connect('IDF_Project::membershipsUpdated', array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('IDF_Project::created', array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('Pluf_User::passwordUpdated', array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('IDF_Project::preDelete', array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('svnpostcommit.php::run', array('IDF_Plugin_SyncSvn', 'entry'));
#
# Mercurial synchronization
Pluf_Signal::connect('IDF_Project::membershipsUpdated', array('IDF_Plugin_SyncMercurial', 'entry'));
Pluf_Signal::connect('IDF_Project::created', array('IDF_Plugin_SyncMercurial', 'entry'));
Pluf_Signal::connect('Pluf_User::passwordUpdated', array('IDF_Plugin_SyncMercurial', 'entry'));
Pluf_Signal::connect('hgchangegroup.php::run', array('IDF_Plugin_SyncMercurial', 'entry'));
#
# Git synchronization
Pluf_Signal::connect('IDF_Project::membershipsUpdated', array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('IDF_Key::postSave', array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('IDF_Project::created', array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('IDF_Key::preDelete', array('IDF_Plugin_SyncGit', 'entry'));
Pluf_Signal::connect('gitpostupdate.php::run', array('IDF_Plugin_SyncGit', 'entry'));
#
# -- Processing of the webhook queue --
Pluf_Signal::connect('queuecron.php::run', array('IDF_Queue', 'process'));
#
# Processing of a given webhook, the hook can be configured
# directly in the configuration file if a different solution
# is required.
Pluf_Signal::connect('IDF_Queue::processItem', Pluf::f('idf_hook_process_item', array('IDF_Webhook', 'process')));
return $m;
Esempio n. 9
0
 /**
  * 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.'));
     }
     // Add a tag for each label
     $tags = array();
     for ($i = 1; $i < 7; $i++) {
         if (strlen($this->cleaned_data['label' . $i]) > 0) {
             if (strpos($this->cleaned_data['label' . $i], ':') !== false) {
                 list($class, $name) = explode(':', $this->cleaned_data['label' . $i], 2);
                 list($class, $name) = array(trim($class), trim($name));
             } else {
                 $class = 'Other';
                 $name = trim($this->cleaned_data['label' . $i]);
             }
             $tags[] = IDF_Tag::add($name, $this->project, $class);
         }
     }
     // Create the upload
     $upload = new IDF_Upload();
     $upload->project = $this->project;
     $upload->submitter = $this->user;
     $upload->summary = trim($this->cleaned_data['summary']);
     $upload->changelog = trim($this->cleaned_data['changelog']);
     $upload->file = $this->cleaned_data['file'];
     $upload->filesize = filesize(Pluf::f('upload_path') . '/' . $this->project->shortname . '/files/' . $this->cleaned_data['file']);
     $upload->downloads = 0;
     $upload->create();
     foreach ($tags as $tag) {
         $upload->setAssoc($tag);
     }
     // Send the notification
     $upload->notify($this->project->getConf());
     /**
      * [signal]
      *
      * IDF_Upload::create
      *
      * [sender]
      *
      * IDF_Form_Upload
      *
      * [description]
      *
      * This signal allows an application to perform a set of tasks
      * just after the upload of a file and after the notification run.
      *
      * [parameters]
      *
      * array('upload' => $upload);
      *
      */
     $params = array('upload' => $upload);
     Pluf_Signal::send('IDF_Upload::create', 'IDF_Form_Upload', $params);
     return $upload;
 }
Esempio n. 10
0
 /**
  * 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.'));
     }
     // Create the review
     $review = new IDF_Review();
     $review->project = $this->project;
     $review->summary = $this->cleaned_data['summary'];
     $review->submitter = $this->user;
     if (!isset($this->cleaned_data['status'])) {
         $this->cleaned_data['status'] = 'New';
     }
     $review->status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
     $review->create();
     // add the first patch
     $patch = new IDF_Review_Patch();
     $patch->review = $review;
     $patch->summary = __('Initial patch to be reviewed.');
     $patch->description = $this->cleaned_data['description'];
     $patch->commit = self::findCommit($this->cleaned_data['commit']);
     $patch->patch = $this->cleaned_data['patch'];
     $patch->create();
     $patch->notify($this->project->getConf());
     /**
      * [signal]
      *
      * IDF_Review::create
      *
      * [sender]
      *
      * IDF_Form_ReviewCreate
      *
      * [description]
      *
      * This signal allows an application to perform a set of tasks
      * just after the creation of a review and the notification.
      *
      * [parameters]
      *
      * array('review' => $review,
      *       'patch' => $patch);
      *
      */
     $params = array('review' => $review, 'patch' => $patch);
     Pluf_Signal::send('IDF_Review::create', 'IDF_Form_ReviewCreate', $params);
     return $review;
 }
Esempio n. 11
0
 * This script will send the notifications after a push in your 
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * svnpostcommit.php::run
 *
 * [sender]
 *
 * svnpostcommit.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * post commit of a subversion repository.
 *
 * [parameters]
 *
 * array('repo_dir' => '/path/to/subversion/repository',
 *       'revision' => 1234,
 *       'env' => array_merge($_ENV, $_SERVER));
 *
 */
$params = array('repo_dir' => $argv[1], 'revision' => $argv[2], 'env' => array_merge($_ENV, $_SERVER));
Pluf_Signal::send('svnpostcommit.php::run', 'svnpostcommit.php', $params);
Esempio n. 12
0
 /**
  * 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.'));
     }
     // Add a tag for each label
     $tags = array();
     for ($i = 1; $i < 7; $i++) {
         if (strlen($this->cleaned_data['label' . $i]) > 0) {
             if (strpos($this->cleaned_data['label' . $i], ':') !== false) {
                 list($class, $name) = explode(':', $this->cleaned_data['label' . $i], 2);
                 list($class, $name) = array(trim($class), trim($name));
             } else {
                 $class = 'Other';
                 $name = trim($this->cleaned_data['label' . $i]);
             }
             $tag = IDF_Tag::add($name, $this->project, $class);
             $tags[] = $tag->id;
         }
     }
     // Create the upload
     $this->upload->summary = trim($this->cleaned_data['summary']);
     $this->upload->changelog = trim($this->cleaned_data['changelog']);
     $this->upload->modif_dtime = gmdate('Y-m-d H:i:s');
     $this->upload->update();
     $this->upload->batchAssoc('IDF_Tag', $tags);
     /**
      * [signal]
      *
      * IDF_Upload::update
      *
      * [sender]
      *
      * IDF_Form_UpdateUpload
      *
      * [description]
      *
      * This signal allows an application to perform a set of tasks
      * just after the update of an uploaded file.
      *
      * [parameters]
      *
      * array('upload' => $upload);
      *
      */
     $params = array('upload' => $this->upload);
     Pluf_Signal::send('IDF_Upload::update', 'IDF_Form_UpdateUpload', $params);
     return $this->upload;
 }
Esempio n. 13
0
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * hgchangegroup.php::run
 *
 * [sender]
 *
 * hgchangegroup.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * group change hook of a Mercurial repository. The rel_dir is a 
 * relative path to the root of your hg repositories but starting with
 * a slash.
 *
 * [parameters]
 *
 * array('rel_dir' => '/relative/path/to/hg/repository',
 *       'env' => array_merge($_ENV, $_SERVER));
 *
 */
$params = array('rel_dir' => $_ENV['PATH_INFO'], 'env' => array_merge($_ENV, $_SERVER));
Pluf_Signal::send('hgchangegroup.php::run', 'hgchangegroup.php', $params);
Esempio n. 14
0
 public function clean()
 {
     if ($this->cleaned_data['scm'] != 'svn') {
         foreach (array('svn_remote_url', 'svn_username', 'svn_password') as $key) {
             $this->cleaned_data[$key] = '';
         }
     }
     /**
      * [signal]
      *
      * IDF_Form_Admin_ProjectCreate::clean
      *
      * [sender]
      *
      * IDF_Form_Admin_ProjectCreate
      *
      * [description]
      *
      * This signal allows an application to clean the form
      * for the creation of a project.
      *
      * [parameters]
      *
      * array('cleaned_data' => $cleaned_data)
      *
      */
     $params = array('cleaned_data' => $this->cleaned_data);
     Pluf_Signal::send('IDF_Form_Admin_ProjectCreate::clean', 'IDF_Form_Admin_ProjectCreate', $params);
     return $this->cleaned_data;
 }
Esempio n. 15
0
 /**
  * The delete() call do not like circular references and the
  * IDF_Tag is creating some. We predelete to solve these issues.
  */
 public function preDelete()
 {
     /**
      * [signal]
      *
      * IDF_Project::preDelete
      *
      * [sender]
      *
      * IDF_Project
      *
      * [description]
      *
      * This signal allows an application to perform special
      * operations at the deletion of a project.
      *
      * [parameters]
      *
      * array('project' => $project)
      *
      */
     $params = array('project' => $this);
     Pluf_Signal::send('IDF_Project::preDelete', 'IDF_Project', $params);
     $what = array('IDF_Upload', 'IDF_Review', 'IDF_Issue', 'IDF_WikiPage', 'IDF_Commit', 'IDF_Tag');
     foreach ($what as $m) {
         foreach (Pluf::factory($m)->getList(array('filter' => 'project=' . (int) $this->id)) as $item) {
             $item->delete();
         }
     }
 }
Esempio n. 16
0
 /**
  * Construct the compiler.
  *
  * @param string Basename of the template file.
  * @param array Base folders in which the templates files 
  *              should be found. (array())
  * @param bool Load directly the template content. (true)
  */
 function __construct($template_file, $folders = array(), $load = true)
 {
     /**
      * [signal]
      *
      * Pluf_Template_Compiler::construct_template_tags_modifiers
      *
      * [sender]
      *
      * Pluf_Template_Compiler
      *
      * [description]
      *
      * This signal allows an application to dynamically modify the
      * allowed template tags. The order of the merge with the ones
      * configured in the configuration files and the default one
      * is: default -> signal -> configuration file.
      * That is, the configuration file is the highest authority.
      *
      * [parameters]
      *
      * array('tags' => array(),
      *       'modifiers' => array());
      *
      */
     $params = array('tags' => array(), 'modifiers' => array());
     Pluf_Signal::send('Pluf_Template_Compiler::construct_template_tags_modifiers', 'Pluf_Template_Compiler', $params);
     $this->_allowedTags = array_merge($this->_allowedTags, $params['tags'], Pluf::f('template_tags', array()));
     $this->_modifier = array_merge($this->_modifier, $params['modifiers'], Pluf::f('template_modifiers', array()));
     foreach ($this->_allowedTags as $name => $model) {
         $this->_extraTags[$name] = new $model();
     }
     $this->_sourceFile = $template_file;
     $this->_allowedInVar = array_merge($this->_vartype, $this->_op);
     $this->_allowedInExpr = array_merge($this->_vartype, $this->_op);
     $this->_allowedAssign = array_merge($this->_vartype, $this->_assignOp, $this->_op);
     $this->templateFolders = $folders;
     if ($load) {
         $this->loadTemplateFile($template_file);
     }
 }
Esempio n. 17
0
/**
 * This script will send the notifications after a push in your 
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * gitpostupdate.php::run
 *
 * [sender]
 *
 * gitpostupdate.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * post update of a git repository.
 *
 * [parameters]
 *
 * array('git_dir' => '/path/to/git/repository.git',
 *       'env' => array_merge($_ENV, $_SERVER));
 *
 */
$params = array('git_dir' => $argv[1], 'env' => array_merge($_ENV, $_SERVER));
Pluf_Signal::send('gitpostupdate.php::run', 'gitpostupdate.php', $params);
Esempio n. 18
0
 public function delete($request, $match)
 {
     $prj = $request->project;
     $upload = Pluf_Shortcuts_GetObjectOr404('IDF_Upload', $match[2]);
     $prj->inOr404($upload);
     $title = sprintf(__('Delete Download %s'), $upload->summary);
     $form = false;
     $ptags = self::getDownloadTags($prj);
     $dtag = array_pop($ptags);
     // The last tag is the deprecated tag.
     $tags = $upload->get_tags_list();
     $deprecated = Pluf_Model_InArray($dtag, $tags);
     if ($request->method == 'POST') {
         $fname = $upload->file;
         @unlink(Pluf::f('upload_path') . '/' . $prj->shortname . '/files/' . $fname);
         /**
          * [signal]
          *
          * IDF_Upload::delete
          *
          * [sender]
          *
          * IDF_Form_UpdateUpload
          *
          * [description]
          *
          * This signal allows an application to perform a set of tasks
          * just before the deletion of the corresponding object in the 
          * database but just after the deletion from the storage.
          *
          * [parameters]
          *
          * array('upload' => $upload);
          *
          */
         $params = array('upload' => $upload);
         Pluf_Signal::send('IDF_Upload::delete', 'IDF_Views_Download', $params);
         $upload->delete();
         $request->user->setMessage(__('The file has been deleted.'));
         $url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index', array($prj->shortname));
         return new Pluf_HTTP_Response_Redirect($url);
     }
     return Pluf_Shortcuts_RenderToResponse('idf/downloads/delete.html', array('file' => $upload, 'deprecated' => $deprecated, 'tags' => $tags, 'page_title' => $title), $request);
 }
Esempio n. 19
0
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
#;*/ ::
$lock_file = Pluf::f('idf_queuecron_lock', Pluf::f('tmp_folder', '/tmp') . '/queuecron.lock');
if (file_exists($lock_file)) {
    Pluf_Log::event(array('queuecron.php', 'skip'));
    return;
}
file_put_contents($lock_file, time(), LOCK_EX);
/**
 * [signal]
 *
 * queuecron.php::run
 *
 * [sender]
 *
 * queuecron.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks when
 * the queue cron job is run. This is done usually every 5 minutes.
 *
 * [parameters]
 *
 * array()
 *
 */
$params = array();
Pluf_Signal::send('queuecron.php::run', 'queuecron.php', $params);
unlink($lock_file);
Esempio n. 20
0
 /**
  * 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 an invalid form.'));
     }
     $this->_user->setFromFormData($this->cleaned_data);
     $this->_user->active = true;
     $this->_user->administrator = false;
     $this->_user->staff = false;
     if ($commit) {
         $this->_user->update();
         /**
          * [signal]
          *
          * Pluf_User::passwordUpdated
          *
          * [sender]
          *
          * IDF_Form_RegisterConfirmation
          *
          * [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_RegisterConfirmation', $params);
     }
     return $this->_user;
 }
Esempio n. 21
0
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * mtnpostpush.php::run
 *
 * [sender]
 *
 * mtnpostpush.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks
 * after a push to a monotone repository.
 *
 * [parameters]
 *
 * array('project' => 'name-of-the-project',
 *       'revisions' => array('123abc...', '456def...', ...));
 *
 */
fwrite(STDERR, "waiting for revisions on STDIN...\n");
$stdin = file_get_contents('php://stdin');
$params = array('project' => $argv[1], 'revisions' => explode("\n", chop($stdin)));
Pluf_Signal::send('mtnpostpush.php::run', 'mtnpostpush.php', $params);
Esempio n. 22
0
 /**
  * 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;
     }
     $this->user->setFromFormData($this->cleaned_data);
     if ($commit) {
         $this->user->update();
         // FIXME: go the extra mile and check the input lengths for
         // all fields here!
         // FIXME: this is all doubled in UserAccount!
         $user_data = IDF_UserData::factory($this->user);
         // Add or remove avatar - we need to do this here because every
         // single setter directly leads to a save in the database
         if ($user_data->avatar != '' && ($this->cleaned_data['remove_custom_avatar'] == 1 || $this->cleaned_data['custom_avatar'] != '')) {
             $avatar_path = Pluf::f('upload_path') . '/avatars/' . basename($user_data->avatar);
             if (basename($avatar_path) != '' && is_file($avatar_path)) {
                 unlink($avatar_path);
             }
             $user_data->avatar = '';
         }
         if ($this->cleaned_data['custom_avatar'] != '') {
             $user_data->avatar = $this->cleaned_data['custom_avatar'];
         }
         $user_data->description = $this->cleaned_data['description'];
         $user_data->twitter = $this->cleaned_data['twitter'];
         $user_data->public_email = $this->cleaned_data['public_email'];
         $user_data->website = $this->cleaned_data['website'];
         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_Admin_UserUpdate', $params);
         }
     }
     return $this->user;
 }
Esempio n. 23
0
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save an invalid form.'));
     }
     $this->user->setFromFormData($this->cleaned_data);
     if ($commit) {
         $this->user->update();
         /**
          * [signal]
          *
          * Pluf_User::passwordUpdated
          *
          * [sender]
          *
          * IDF_Form_PasswordReset
          *
          * [description]
          *
          * This signal is sent when the user reset his
          * password from the password recovery page.
          *
          * [parameters]
          *
          * array('user' => $user)
          *
          */
         $params = array('user' => $this->user);
         Pluf_Signal::send('Pluf_User::passwordUpdated', 'IDF_Form_PasswordReset', $params);
     }
     return $this->user;
 }
Esempio n. 24
0
 /**
  * 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;
     }
     $this->user->setFromFormData($this->cleaned_data);
     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_Admin_UserUpdate', $params);
         }
     }
     return $this->user;
 }
Esempio n. 25
0
 /**
  * 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.'));
     }
     // Add a tag for each label
     $tags = array();
     if ($this->show_full) {
         for ($i = 1; $i < 7; $i++) {
             if (strlen($this->cleaned_data['label' . $i]) > 0) {
                 if (strpos($this->cleaned_data['label' . $i], ':') !== false) {
                     list($class, $name) = explode(':', $this->cleaned_data['label' . $i], 2);
                     list($class, $name) = array(trim($class), trim($name));
                 } else {
                     $class = 'Other';
                     $name = trim($this->cleaned_data['label' . $i]);
                 }
                 $tags[] = IDF_Tag::add($name, $this->project, $class);
             }
         }
     } else {
         $tags[] = IDF_Tag::add('Medium', $this->project, 'Priority');
         $tags[] = IDF_Tag::add('Defect', $this->project, 'Type');
     }
     // Create the issue
     $issue = new IDF_Issue();
     $issue->project = $this->project;
     $issue->submitter = $this->user;
     if ($this->show_full) {
         $issue->status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
         $issue->owner = self::findUser($this->cleaned_data['owner']);
     } else {
         $_t = $this->project->getTagIdsByStatus('open');
         $issue->status = new IDF_Tag($_t[0]);
         // first one is the default
         $issue->owner = null;
     }
     $issue->summary = trim($this->cleaned_data['summary']);
     $issue->create();
     foreach ($tags as $tag) {
         $issue->setAssoc($tag);
     }
     // add the first comment
     $comment = new IDF_IssueComment();
     $comment->issue = $issue;
     $comment->content = $this->cleaned_data['content'];
     $comment->submitter = $this->user;
     $comment->create();
     // If we have a file, create the IDF_IssueFile and attach
     // it to the comment.
     $created_files = array();
     for ($i = 1; $i < 4; $i++) {
         if ($this->cleaned_data['attachment' . $i]) {
             $file = new IDF_IssueFile();
             $file->attachment = $this->cleaned_data['attachment' . $i];
             $file->submitter = $this->user;
             $file->comment = $comment;
             $file->create();
             $created_files[] = $file;
         }
     }
     /**
      * [signal]
      *
      * IDF_Issue::create
      *
      * [sender]
      *
      * IDF_Form_IssueCreate
      *
      * [description]
      *
      * This signal allows an application to perform a set of tasks
      * just after the creation of an issue. The comment contains
      * the description of the issue.
      *
      * [parameters]
      *
      * array('issue' => $issue,
      *       'comment' => $comment,
      *       'files' => $attached_files);
      *
      */
     $params = array('issue' => $issue, 'comment' => $comment, 'files' => $created_files);
     Pluf_Signal::send('IDF_Issue::create', 'IDF_Form_IssueCreate', $params);
     return $issue;
 }
Esempio n. 26
0
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * svnpostrevpropchange.php::run
 *
 * [sender]
 *
 * svnpostrevpropchange.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * post property revision change of a subversion repository.
 *
 * [parameters]
 *
 * array('repo_dir' => '/path/to/subversion/repository',
 *       'revision' => 1234,
 *       'user' => 'username',
 *       'propname' => 'changed-property',
 *       'action' => 'the action M, A or D',
 *       'env' => array_merge($_ENV, $_SERVER));
 *
 */
$params = array('repo_dir' => $argv[1], 'revision' => $argv[2], 'user' => $argv[3], 'propname' => $argv[4], 'action' => $argv[5], 'env' => array_merge($_ENV, $_SERVER));
Pluf_Signal::send('svnpostrevpropchange.php::run', 'svnpostrevpropchange.php', $params);
Esempio n. 27
0
 public static function process()
 {
     while (false !== ($q = self::getItem())) {
         /**
          * [signal]
          *
          * Pluf_Queue_Processor::process
          *
          * [sender]
          *
          * Pluf_Queue_Processor
          *
          * [description]
          *
          * This signal allows an application to perform an action on a
          * queue item. The item is set to null if none existing.
          *
          * You must not modify the 'queue' object.
          *
          * [parameters]
          *
          * array('item' => $item, 'queue' => $queue);
          *
          *
          */
         Pluf_Signal::send('Pluf_Queue_Processor::process', 'Pluf_Queue_Process', $q);
         $q['queue']->lock = 2;
         $q['queue']->update();
     }
 }
Esempio n. 28
0
 function preDelete()
 {
     /**
      * [signal]
      *
      * IDF_Key::preDelete
      *
      * [sender]
      *
      * IDF_Key
      *
      * [description]
      *
      * This signal allows an application to perform special
      * operations before a key is deleted.
      *
      * [parameters]
      *
      * array('key' => $key)
      *
      */
     $params = array('key' => $this);
     Pluf_Signal::send('IDF_Key::preDelete', 'IDF_Key', $params);
 }
Esempio n. 29
0
 /**
  * Predelete to drop the row level permissions.
  */
 function preDelete()
 {
     /**
      * [signal]
      *
      * Pluf_User::preDelete
      *
      * [sender]
      *
      * Pluf_User
      *
      * [description]
      *
      * This signal allows an application to perform special
      * operations at the deletion of a user.
      *
      * [parameters]
      *
      * array('user' => $user)
      *
      */
     $params = array('user' => $this);
     Pluf_Signal::send('Pluf_User::preDelete', 'Pluf_User', $params);
     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());
     }
 }
Esempio n. 30
0
 /**
  * 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.'));
     }
     if ($this->show_full) {
         // Add a tag for each label
         $tags = array();
         $tagids = array();
         for ($i = 1; $i < 7; $i++) {
             if (strlen($this->cleaned_data['label' . $i]) > 0) {
                 if (strpos($this->cleaned_data['label' . $i], ':') !== false) {
                     list($class, $name) = explode(':', $this->cleaned_data['label' . $i], 2);
                     list($class, $name) = array(trim($class), trim($name));
                 } else {
                     $class = 'Other';
                     $name = trim($this->cleaned_data['label' . $i]);
                 }
                 $tag = IDF_Tag::add($name, $this->project, $class);
                 $tags[] = $tag;
                 $tagids[] = $tag->id;
             }
         }
         // Compare between the old and the new data
         $changes = array();
         $oldtags = $this->issue->get_tags_list();
         foreach ($tags as $tag) {
             if (!Pluf_Model_InArray($tag, $oldtags)) {
                 if (!isset($changes['lb'])) {
                     $changes['lb'] = array();
                 }
                 if ($tag->class != 'Other') {
                     $changes['lb'][] = (string) $tag;
                     //new tag
                 } else {
                     $changes['lb'][] = (string) $tag->name;
                 }
             }
         }
         foreach ($oldtags as $tag) {
             if (!Pluf_Model_InArray($tag, $tags)) {
                 if (!isset($changes['lb'])) {
                     $changes['lb'] = array();
                 }
                 if ($tag->class != 'Other') {
                     $changes['lb'][] = '-' . (string) $tag;
                     //new tag
                 } else {
                     $changes['lb'][] = '-' . (string) $tag->name;
                 }
             }
         }
         // Status, summary and owner
         $status = IDF_Tag::add(trim($this->cleaned_data['status']), $this->project, 'Status');
         if ($status->id != $this->issue->status) {
             $changes['st'] = $status->name;
         }
         if (trim($this->issue->summary) != trim($this->cleaned_data['summary'])) {
             $changes['su'] = trim($this->cleaned_data['summary']);
         }
         $owner = self::findUser($this->cleaned_data['owner']);
         if (is_null($owner) and !is_null($this->issue->get_owner()) or !is_null($owner) and is_null($this->issue->get_owner()) or !is_null($owner) and !is_null($this->issue->get_owner()) and $owner->id != $this->issue->get_owner()->id) {
             $changes['ow'] = is_null($owner) ? '---' : $owner->login;
         }
         // Update the issue
         $this->issue->batchAssoc('IDF_Tag', $tagids);
         $this->issue->summary = trim($this->cleaned_data['summary']);
         $this->issue->status = $status;
         $this->issue->owner = $owner;
     }
     // Create the comment
     $comment = new IDF_IssueComment();
     $comment->issue = $this->issue;
     $comment->content = $this->cleaned_data['content'];
     $comment->submitter = $this->user;
     if (!$this->show_full) {
         $changes = array();
     }
     $comment->changes = $changes;
     $comment->create();
     $this->issue->update();
     if ($this->issue->owner != $this->user->id and $this->issue->submitter != $this->user->id) {
         $this->issue->setAssoc($this->user);
         // interested user.
     }
     $attached_files = array();
     for ($i = 1; $i < 4; $i++) {
         if ($this->cleaned_data['attachment' . $i]) {
             $file = new IDF_IssueFile();
             $file->attachment = $this->cleaned_data['attachment' . $i];
             $file->submitter = $this->user;
             $file->comment = $comment;
             $file->create();
             $attached_files[] = $file;
         }
     }
     /**
      * [signal]
      *
      * IDF_Issue::update
      *
      * [sender]
      *
      * IDF_Form_IssueUpdate
      *
      * [description]
      *
      * This signal allows an application to perform a set of tasks
      * just after the update of an issue.
      *
      * [parameters]
      *
      * array('issue' => $issue,
      *       'comment' => $comment,
      *       'files' => $attached_files);
      *
      */
     $params = array('issue' => $this->issue, 'comment' => $comment, 'files' => $attached_files);
     Pluf_Signal::send('IDF_Issue::update', 'IDF_Form_IssueUpdate', $params);
     return $this->issue;
 }