Esempio n. 1
0
 function save_lines($post_data, $parent, $key = '')
 {
     $line_count = count($post_data[$key . 'action']);
     $j = 0;
     for ($i = 0; $i < $line_count; ++$i) {
         if ($post_data[$key . 'deleted'][$i] == 1) {
             $this->mark_deleted($post_data[$key . 'id'][$i]);
         } else {
             $action = new AOW_Action();
             foreach ($this->field_defs as $field_def) {
                 if (isset($post_data[$key . $field_def['name']][$i])) {
                     $action->{$field_def}['name'] = $post_data[$key . $field_def['name']][$i];
                 }
             }
             $params = array();
             foreach ($post_data[$key . 'param'][$i] as $param_name => $param_value) {
                 $params[$param_name] = $param_value;
             }
             $action->parameters = base64_encode(serialize($params));
             if (trim($action->action) != '') {
                 $action->action_order = ++$j;
                 $action->assigned_user_id = $parent->assigned_user_id;
                 $action->aow_workflow_id = $parent->id;
                 $action->save();
             }
         }
     }
 }
Esempio n. 2
0
 public function testbean_implements()
 {
     error_reporting(E_ERROR | E_PARSE);
     $aowAction = new AOW_Action();
     $this->assertEquals(false, $aowAction->bean_implements(''));
     //test with blank value
     $this->assertEquals(false, $aowAction->bean_implements('test'));
     //test with invalid value
     $this->assertEquals(false, $aowAction->bean_implements('ACL'));
     //test with valid value
 }
Esempio n. 3
0
/**
 * Advanced OpenWorkflow, Automating SugarCRM.
 * @package Advanced OpenWorkflow for SugarCRM
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author SalesAgility <*****@*****.**>
 */
function display_action_lines(SugarBean $focus, $field, $value, $view)
{
    global $locale, $app_list_strings, $mod_strings;
    $html = '';
    if (!is_file('cache/jsLanguage/AOW_Actions/' . $GLOBALS['current_language'] . '.js')) {
        require_once 'include/language/jsLanguage.php';
        jsLanguage::createModuleStringsCache('AOW_Actions', $GLOBALS['current_language']);
    }
    $html .= '<script src="cache/jsLanguage/AOW_Actions/' . $GLOBALS['current_language'] . '.js"></script>';
    if ($view == 'EditView') {
        $html .= '<script src="modules/AOW_Actions/actionLines.js"></script>';
        $aow_actions_list = array();
        include_once 'modules/AOW_Actions/actions.php';
        $app_list_actions[''] = '';
        foreach ($aow_actions_list as $action_value) {
            $action_name = 'action' . $action_value;
            if (file_exists('custom/modules/AOW_Actions/actions/' . $action_name . '.php')) {
                require_once 'custom/modules/AOW_Actions/actions/' . $action_name . '.php';
            } else {
                if (file_exists('modules/AOW_Actions/actions/' . $action_name . '.php')) {
                    require_once 'modules/AOW_Actions/actions/' . $action_name . '.php';
                } else {
                    continue;
                }
            }
            $action = new $action_name();
            foreach ($action->loadJS() as $js_file) {
                $html .= '<script src="' . $js_file . '"></script>';
            }
            $app_list_actions[$action_value] = translate('LBL_' . strtoupper($action_value), 'AOW_Actions');
        }
        $html .= '<input type="hidden" name="app_list_actions" id="app_list_actions" value="' . get_select_options_with_id($app_list_actions, '') . '">';
        $html .= "<table style='padding-top: 10px; padding-bottom:10px;' id='actionLines'></table>";
        $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>";
        $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"" . $mod_strings['LBL_ADD_ACTION'] . "\" id=\"btn_ActionLine\" onclick=\"insertActionLine()\" disabled/>";
        $html .= "</div>";
        if (isset($focus->flow_module) && $focus->flow_module != '') {
            $html .= "<script>document.getElementById('btn_ActionLine').disabled = '';</script>";
            if ($focus->id != '') {
                $sql = "SELECT id FROM aow_actions WHERE aow_workflow_id = '" . $focus->id . "' AND deleted = 0 ORDER BY action_order ASC";
                $result = $focus->db->query($sql);
                while ($row = $focus->db->fetchByAssoc($result)) {
                    $action_name = new AOW_Action();
                    $action_name->retrieve($row['id']);
                    $action_item = json_encode($action_name->toArray());
                    $html .= "<script>\n                            loadActionLine(" . $action_item . ");\n                        </script>";
                }
            }
        }
    } else {
        if ($view == 'DetailView') {
            $html .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
            $sql = "SELECT id FROM aow_actions WHERE aow_workflow_id = '" . $focus->id . "' AND deleted = 0 ORDER BY action_order ASC";
            $result = $focus->db->query($sql);
            while ($row = $focus->db->fetchByAssoc($result)) {
                $action_name = new AOW_Action();
                $action_name->retrieve($row['id']);
                $html .= "<tr><td>" . $action_name->action_order . "</td><td>" . $action_name->name . "</td><td>" . translate('LBL_' . strtoupper($action_name->action), 'AOW_Actions') . "</td></tr>";
            }
            $html .= "</table>";
        }
    }
    return $html;
}
Esempio n. 4
0
 protected function action_getAction()
 {
     global $beanList, $beanFiles;
     $action_name = 'action' . $_REQUEST['aow_action'];
     $line = $_REQUEST['line'];
     if ($_REQUEST['aow_module'] == '' || !isset($beanList[$_REQUEST['aow_module']])) {
         echo '';
         die;
     }
     if (file_exists('custom/modules/AOW_Actions/actions/' . $action_name . '.php')) {
         require_once 'custom/modules/AOW_Actions/actions/' . $action_name . '.php';
     } else {
         if (file_exists('modules/AOW_Actions/actions/' . $action_name . '.php')) {
             require_once 'modules/AOW_Actions/actions/' . $action_name . '.php';
         } else {
             echo '';
             die;
         }
     }
     $custom_action_name = "custom" . $action_name;
     if (class_exists($custom_action_name)) {
         $action_name = $custom_action_name;
     }
     $id = '';
     $params = array();
     if (isset($_REQUEST['id'])) {
         require_once 'modules/AOW_Actions/AOW_Action.php';
         $aow_action = new AOW_Action();
         $aow_action->retrieve($_REQUEST['id']);
         $id = $aow_action->id;
         $params = unserialize(base64_decode($aow_action->parameters));
     }
     $action = new $action_name($id);
     require_once $beanFiles[$beanList[$_REQUEST['aow_module']]];
     $bean = new $beanList[$_REQUEST['aow_module']]();
     echo $action->edit_display($line, $bean, $params);
     die;
 }
Esempio n. 5
0
 /**
  * Run the actions against the passed $bean
  */
 function run_actions(SugarBean $bean)
 {
     require_once 'modules/AOW_Processed/AOW_Processed.php';
     $processed = new AOW_Processed();
     if (!$this->multiple_runs) {
         $processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id));
         if ($processed->status == 'Complete') {
             //should not have gotten this far, so return
             return true;
         }
     }
     $processed->aow_workflow_id = $this->id;
     $processed->parent_id = $bean->id;
     $processed->parent_type = $bean->module_dir;
     $processed->status = 'Running';
     $processed->save(false);
     $processed->load_relationship('aow_actions');
     $pass = true;
     $sql = "SELECT id FROM aow_actions WHERE aow_workflow_id = '" . $this->id . "' AND deleted = 0 ORDER BY action_order ASC";
     $result = $this->db->query($sql);
     while ($row = $this->db->fetchByAssoc($result)) {
         $action = new AOW_Action();
         $action->retrieve($row['id']);
         if ($this->multiple_runs || !$processed->db->getOne("select id from aow_processed_aow_actions where aow_processed_id = '" . $processed->id . "' AND aow_action_id = '" . $action->id . "' AND status = 'Complete'")) {
             $action_name = 'action' . $action->action;
             if (file_exists('custom/modules/AOW_Actions/actions/' . $action_name . '.php')) {
                 require_once 'custom/modules/AOW_Actions/actions/' . $action_name . '.php';
             } else {
                 if (file_exists('modules/AOW_Actions/actions/' . $action_name . '.php')) {
                     require_once 'modules/AOW_Actions/actions/' . $action_name . '.php';
                 } else {
                     return false;
                 }
             }
             $flow_action = new $action_name($action->id);
             if (!$flow_action->run_action($bean, unserialize(base64_decode($action->parameters)))) {
                 $pass = false;
                 $processed->aow_actions->add($action->id, array('status' => 'Failed'));
             } else {
                 $processed->aow_actions->add($action->id, array('status' => 'Complete'));
             }
         }
     }
     if ($pass) {
         $processed->status = 'Complete';
     } else {
         $processed->status = 'Failed';
     }
     $processed->save(false);
     return $pass;
 }